wsl Ubuntu24.04搭建开发环境教程

摘要:记录在Windows11系统上安装wsl2虚拟机后,在Ubuntu24.04系统上搭建开发环境全过程。

显卡驱动

必须注意到的是,在安装Ubuntu24.04系统之前的显卡驱动更新才有效,安装后的更新在子系统无效!

如果显卡驱动下载失败,前往C:\ProgramData\NVIDIA Corporation\Downloader手动更新(下载的安装包会自动删除导致下载失败)

当前显卡驱动版本为:581.29

安装miniconda

在shell中输入:

1
2
3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
sudo chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh

然后添加环境变量:export PATH=/home/lqb/miniconda3/enter/bin:$PATH

conda换源:

1
2
3
4
5
6
7
8
9
10
11
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
auto_activate: false

安装cuda、cudnn

网址:cuda cudnn

我的版本为:cuda13.0.0 + cudnn9.12.0

安装过程(跟着官网一样就行,最好是先下载安装包放在home文件夹):

1
2
3
4
5
6
7
8
# cuda
sudo sh cuda_13.0.0_580.65.06_linux.run

# cudnn
sudo dpkg -i cudnn-local-repo-ubuntu2404-9.12.0_1.0-1_amd64.deb
sudo cp /var/cudnn-local-repo-ubuntu2404-9.12.0/cudnn-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cudnn9-cuda-13

添加环境变量:

1
2
3
export PATH=/usr/local/cuda-13.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-13.0/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-13.0/extras/CUPTI/lib64

虚拟环境记录

jax(py3.11.8)

1
2
3
4
5
6
pip install --upgrade "jax[cuda12]"
pip install ipykernel
pip install jax_cfd
pip install keras
pip install xarray
pip install seaborn

study(py3.11.8)

1
2
3
4
5
6
7
8
9
10
11
Pip install numpy
Pip install ipykernel
Pip install scipy
Pip install matplotlib
Pip install pandas
Pip install statsmodels
Pip install scikit-learn
Pip install plotly
Pip install seaborn
Pip install nbformat
Pip install openpyxl

pytorch(py3.11.8)

1
2
3
4
5
6
7
8
9
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu130
pip install tensorboard
pip install tqdm
pip install ipykernel # 用vscode的jupyternotebook运行必装
pip install matplotlib
pip install pandas
pip install neuraloperator
pip install xarray
pip install seaborn

tf(py3.11.8)

1
pip install tensorflow[and-cuda]

yolov8_bags

1
2
3
4
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu130
pip install ultralyticd
pip install seaborn
pip install ipykernel

其他

删除Zone.Identifier:

1
find . -name "*:Zone.Identifier" -type f -delete`

······持续更新中