from selenium import webdriver from selenium.webdriver.firefox.options import Options from pyvirtualdisplay import Display from selenium.webdriver.chrome.service import Service from selenium.webdriver.firefox.firefox_binary import FirefoxBinary from selenium.webdriver.common.by import By import os import time
#!/bin/bash # Default Docker image DEFAULT_IMAGE="vllm:2.32.0.11-torch2.4-py310-ubuntu20.04-amd64" # Check if an image name is provided as an argument if [ -n "$1" ]; then DOCKER_IMAGE="$1" else DOCKER_IMAGE="$DEFAULT_IMAGE" fi # Start building the docker run command DOCKER_COMMAND="nerdctl -n k8s.io --address /data/containerd/run/containerd.sock run" # Add the always-included device if it exists if [ -e "/dev/htcd" ]; then DOCKER_COMMAND+=" --device=/dev/htcd" else echo "Warning: /dev/htcd not found on the host." fi # Get all devices under /dev/dri and add them to the command if [ -d "/dev/dri" ]; then for device in /dev/dri/*; do if [ -c "$device" ]; then # Check if it's a character device DOCKER_COMMAND+=" --device=$device" fi done else echo "Error: /dev/dri directory not found on the host. Graphics devices might not be available." exit 1 fi # Add the rest of your docker command using the chosen image DOCKER_COMMAND+=" -it ${DOCKER_IMAGE} /bin/bash" # Print the generated command echo "Generated Docker command:" echo "$DOCKER_COMMAND" # Execute the command (uncomment the line below to actually run it) eval "$DOCKER_COMMAND"
#!/bin/bash # Enable shell tracing for debugging (optional, can be removed once confident) # set -x # --- IMPORTANT: Find your DOCKER/NERDCTL executable path --- # 1. Deactivate conda: `conda deactivate` # 2. Run: `which docker` # 3. If it points to a script/symlink that calls nerdctl, use that script's path. # Otherwise, use the direct binary path shown by `which docker`. # Example: DOCKER_BIN="/usr/bin/docker" # If `which docker` gives no output outside conda, you'll need to find it manually: # `find / -name docker -type f 2>/dev/null | grep -E "(bin/docker|sbin/docker)"` # Once found, replace the placeholder below with the actual path. DOCKER_BIN="nerdctl -n k8s.io --address /data/containerd/run/containerd.sock" # <--- REPLACE THIS WITH YOUR ACTUAL DOCKER/NERDCTL PATH # Default Docker image (used if not provided as the second argument) DEFAULT_IMAGE="vllm:2.32.0.11-torch2.4-py310-ubuntu20.04-amd64" # --- Argument Parsing --- # Check for at least one argument (mapping directory) if [ -z "$1" ]; then echo "Usage: $0 <host_dir_to_map> [docker_image_name]" echo " <host_dir_to_map>: The host directory to mount into the container (e.g., /home/user/data:/app/data)" echo " [docker_image_name]: Optional. The Docker image to use. Defaults to ${DEFAULT_IMAGE}" exit 1 fi
MAPPED_DIR="$1" # First argument is the directory mapping # Check for the second argument (Docker image name) if [ -n "$2" ]; then DOCKER_IMAGE="$2" else DOCKER_IMAGE="$DEFAULT_IMAGE" fi # Start building the docker run command DOCKER_COMMAND="${DOCKER_BIN} run" # Add the directory mapping DOCKER_COMMAND+=" -v ${MAPPED_DIR}" # Add the always-included device if it exists if [ -e "/dev/htcd" ]; then DOCKER_COMMAND+=" --device=/dev/htcd" else echo "Warning: /dev/htcd not found on the host." fi # Get all devices under /dev/dri and add them to the command if [ -d "/dev/dri" ]; then for device in /dev/dri/*; do if [ -c "$device" ]; then # Check if it's a character device DOCKER_COMMAND+=" --device=$device" fi done else echo "Error: /dev/dri directory not found on the host. Graphics devices might not be available." exit 1 fi # Add the rest of your docker command using the chosen image DOCKER_COMMAND+=" -it ${DOCKER_IMAGE} /bin/bash" # Print the generated command before execution echo "-------------------------------------" echo "Generated command string (before eval):" echo "$DOCKER_COMMAND" echo "-------------------------------------" # Execute the command (uncomment the line below to actually run it) eval "$DOCKER_COMMAND" # Disable shell tracing (if enabled) # set +x
#!/bin/bash # Enable shell tracing for debugging (optional, can be removed once confident) # set -x # --- IMPORTANT: Find your DOCKER/NERDCTL executable path --- # 1. Deactivate conda: `conda deactivate` # 2. Run: `which docker` # 3. If it points to a script/symlink that calls nerdctl, use that script's path. # Otherwise, use the direct binary path shown by `which docker`. # Example: DOCKER_BIN="/usr/bin/docker" # If `which docker` gives no output outside conda, you'll need to find it manually: # `find / -name docker -type f 2>/dev/null | grep -E "(bin/docker|sbin/docker)"` # Once found, replace the placeholder below with the actual path. DOCKER_BIN="nerdctl -n k8s.io --address /data/containerd/run/containerd.sock" # <--- REPLACE THIS WITH YOUR ACTUAL DOCKER/NERDCTL PATH # Default Docker image (used if not provided as the second argument) DEFAULT_IMAGE="vllm:2.32.0.11-torch2.4-py310-ubuntu20.04-amd64"
DOCKER_IMAGE="${DOCKER_IMAGE:-$DEFAULT_IMAGE}" # Check if at least one volume mapping argument is provided. # "$#" holds the total number of command-line arguments. if [ "$#" -eq 0 ]; then echo "Error: At least one volume mapping is required." echo echo "Usage: [DOCKER_IMAGE=<image_name>] $0 <host_dir1:container_dir1> [<host_dir2:container_dir2> ...]" echo echo "Description:" echo " This script starts a Docker container and maps one or more host directories" echo " into the container." echo echo "Arguments:" echo " <host_dir:container_dir> A directory to mount, with host and container paths separated by a colon." echo " Multiple mapping arguments can be provided." echo echo "Environment Variable:" echo " DOCKER_IMAGE The Docker image to use. Defaults to: '${DEFAULT_IMAGE}'" echo echo "Examples:" echo " # Map a single directory using the default image (${DEFAULT_IMAGE})" echo " $0 /home/user/data:/app/data" echo echo " # Map multiple directories with a specific image" echo " DOCKER_IMAGE=python:3.9-slim $0 /home/user/project:/app /home/user/logs:/logs" exit 1 fi # Start building the docker run command DOCKER_COMMAND="${DOCKER_BIN} run -it --rm" # Iterate over all command-line arguments. # "$@" treats each command-line argument as a separate, quoted string. for mapping in "$@"; do # For each argument, add the "-v" flag and the mapping itself to our command array. DOCKER_COMMAND+=" -v ${mapping}" done # Add the always-included device if it exists if [ -e "/dev/htcd" ]; then DOCKER_COMMAND+=" --device=/dev/htcd" else echo "Warning: /dev/htcd not found on the host." fi # Get all devices under /dev/dri and add them to the command if [ -d "/dev/dri" ]; then for device in /dev/dri/*; do if [ -c "$device" ]; then # Check if it's a character device DOCKER_COMMAND+=" --device=$device" fi done else echo "Error: /dev/dri directory not found on the host. Graphics devices might not be available." exit 1 fi # Add the rest of your docker command using the chosen image DOCKER_COMMAND+=" ${DOCKER_IMAGE} /bin/bash" # Print the generated command before execution echo "-------------------------------------" echo "Generated command string (before eval):" echo "$DOCKER_COMMAND" echo "-------------------------------------" # Execute the command (uncomment the line below to actually run it) eval "$DOCKER_COMMAND" # Disable shell tracing (if enabled) # set +x