OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.
conda install -c conda-forge cudatoolkit-dev -y
https://stackoverflow.com/questions/52731782/get-cuda-home-environment-path-pytorch
Conda environments not showing up in Jupyter Notebook
source activate myenv
pip install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
Creating the Jupyter Kernel
The following command will create a jupyter kernel from an existing mamba environment:
Do not activate the environment when running this command
$ mkjupy <environment> "Icon Label"
Example (do not activate the nobel environment):
$ mkjupy nobel "noble"
Expected output example:
$ Installed kernelspec nobel in /home/spock/.local/share/jupyter/kernels/nobel
设置可见GPU
import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
# 需要在import torch之前执行
import torch
CUDA_VISIBLE_DEVICES=5, python test_script.py
https://stackoverflow.com/questions/39649102/how-do-i-select-which-gpu-to-run-a-job-on
clearing the occupied cuda memory
import torch
torch.cuda.empty_cache()
https://stackoverflow.com/questions/59129812/how-to-avoid-cuda-out-of-memory-in-pytorch