New WSL#
- Visit the store to get Windows Subsystem for Linux
- Use
wsl --version
to directly jump to step 4: Install Docker - Outdated tutorials are harmful
- If you have already completed steps 2 and 3, after the update, you need to execute
wsl -s docker-desktop
again to switch back to the correct distro. Switch back to the correct distro - Disable Hyper-V and only enable WSL and Virtualization Platform as optional features
- Run
netsh winsock reset
and then restart the computer
Enable Hyper-V by Yi Bai#
- Copy the following content to a text file, then name the file Hyper-V.bat, and run it as an administrator. After running, restart the computer (you may need to enable processor virtualization support in the BIOS).
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
- Enable Hyper-V using PowerShell. Open PowerShell console as an administrator and run the following command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Install WSL2 by Ali7&MS#
- Search for Ubuntu 22.04.2 LTS in the Microsoft Store and install it (optional)
- Enable Windows Subsystem for Linux
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- Enable Virtual Machine Platform
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- Download and install the WSL2 update package
- Set WSL2 as the default version
wsl --set-default-version 2
- Run the installed Ubuntu 22.04.2 LTS from the store (optional)
Install Docker Desktop by Time Chaser#
- Download Docker Desktop Installer
- Change the source. Right-click on the Docker Desktop icon in the system tray and select Settings. In the opened configuration window, select Docker Desktop from the left navigation menu. Edit the JSON string in the editing window:
{
"builder": {
"features": {
"buildkit": true
},
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"registry-mirrors": [
"https://hub-mirror.c.163.com/",
"https://docker.mirrors.ustc.edu.cn/"
]
}
- Test by running
docker run hello-world
in PowerShell
Use Nvidia by Unknown&bpq#
- Run
nvidia-smi
in Ubuntu 22.04.2 LTS
- Uninstall Ubuntu 22.04.2 LTS, make sure you have docker-desktop and docker-desktop-data by running
wsl -l -v
- Run
docker pull anibali/pytorch:2.0.0-cuda11.8-ubuntu22.04
in PowerShell - Start the container and test cuda
docker run -p 0.0.0.0:8001:8001 --rm -it --name torch --gpus all anibali/pytorch:2.0.0-cuda11.8-ubuntu22.04 /bin/bash
python
import torch # Import if PyTorch is successfully installed
print(torch.cuda.is_available()) # Check if CUDA is available
print(torch.cuda.device_count()) # Check the number of available CUDA devices
print(torch.version.cuda) # Check the version of CUDA
- Test network access, pay attention to
-p 0.0.0.0
docker run -p 0.0.0.0:8001:8001 --rm -it --name torch --gpus all anibali/pytorch:2.0.0-cuda11.8-ubuntu22.04 python -m http.server 8001
Conda by bpq&LATLAJ#
mkdir data # G:\data
docker run -p 0.0.0.0:8001:8001 -it --name torch --gpus all -v //g/data:/app/data anibali/pytorch:2.0.0-cuda11.8-ubuntu22.04 /bin/bash
conda init # Then exit bash
docker start torch
docker exec -it torch /bin/bash
conda install nano -c conda-forge
nano ~/.condarc
Jupyter#
conda create -n jupyter jupyter notebook -c conda-forge
conda activate jupyter
jupyter notebook --ip 0.0.0.0 --port 8001
jupyter notebook --generate-config
nano ~/.jupyter/jupyter_notebook_config.py
jupyter notebook # http://localhost:8001/lab?token=limour
c.ServerApp.ip = '*'
c.ServerApp.port = 8001
c.ExtensionApp.open_browser = False
c.ServerApp.token = 'limour'
Add kernel#
conda activate base
conda install ipykernel -c conda-forge
python -m ipykernel install --user --name pytorch
Quick start: docker exec -it torch /home/user/micromamba/envs/jupyter/bin/jupyter notebook