File size: 3,425 Bytes
0210a65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
https://github.com/mani-skill/ManiSkill#!/bin/bash
# ==============================================================================
# WSL2 Setup Script for Certified Safe Neural Control Under Distribution Shift
# Target: Ubuntu 22.04 LTS on WSL2 with NVIDIA CUDA 12.x Passthrough
# ==============================================================================

set -e

echo "=== [1/6] Updating System & Installing Core Packages ==="
if command -v cmake &> /dev/null && command -v vulkaninfo &> /dev/null; then
    echo "[+] Core graphics and build packages already installed. Skipping apt-get."
else
    sudo apt-get update && sudo apt-get install -y \
        build-essential \
        cmake \
        git \
        curl \
        wget \
        libgl1 \
        libegl1 \
        libglvnd0 \
        libglx0 \
        libvulkan1 \
        vulkan-tools \
        python3-dev
fi

echo "=== [2/6] Verifying NVIDIA Driver Passthrough in WSL2 ==="
if command -v nvidia-smi &> /dev/null; then
    nvidia-smi
    echo "[+] NVIDIA Driver passthrough detected successfully!"
else
    echo "[!] WARNING: nvidia-smi not found. Ensure NVIDIA Windows Driver with WSL2 support is installed."
fi

echo "=== [3/6] Setting Up Conda Environment ==="
if ! command -v conda &> /dev/null && [ ! -f "$HOME/miniconda3/bin/conda" ]; then
    echo "Miniconda not detected. Installing Miniconda..."
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh
    bash /tmp/miniconda.sh -b -u -p ~/miniconda3
    rm -f /tmp/miniconda.sh
    export PATH="$HOME/miniconda3/bin:$PATH"
    ~/miniconda3/bin/conda init bash
else
    echo "[+] Miniconda already installed."
    export PATH="$HOME/miniconda3/bin:$PATH"
fi

source ~/.bashrc || true
export PATH="$HOME/miniconda3/bin:$PATH"

# Accept Conda Terms of Service for default channels if prompted
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main 2>/dev/null || true
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r 2>/dev/null || true

# Add conda-forge channel for community packages
conda config --add channels conda-forge 2>/dev/null || true

if conda info --envs | grep -q "cbf-shift"; then
    echo "[+] Environment 'cbf-shift' already exists. Activating..."
else
    echo "[+] Creating 'cbf-shift' environment with Python 3.10..."
    conda create -n cbf-shift python=3.10 -y
fi

eval "$(conda shell.bash hook)"
conda activate cbf-shift

echo "=== [4/6] Installing PyTorch with CUDA 12.1 ==="
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121

echo "=== [5/6] Installing CVXPY, OSQP, and Optimization Solvers ==="
pip install cvxpy osqp qpsolvers[open_source] numpy scipy matplotlib pandas hydra-core pytest tqdm

echo "=== [6/6] Installing ManiSkill3 (Dual-Mode: GPU & CPU Support) ==="
# ManiSkill3 supports both GPU (PhysX/Vulkan) and CPU simulation
pip install mani-skill

echo "=== [Done] Validating PyTorch & CUDA ==="
python -c "import torch; print(f'PyTorch {torch.__version__} | CUDA Available: {torch.cuda.is_available()} | Device: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else \"CPU\"}')"

echo "=========================================================================="
echo "WSL2 Environment Ready! Activate with: conda activate cbf-shift"
echo "=========================================================================="