【conda】环境配置

发布于:2024-12-06 ⋅ 阅读:(25) ⋅ 点赞:(0)

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)"

https://stackoverflow.com/questions/39604271/conda-environments-not-showing-up-in-jupyter-notebook?rq=2

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


网站公告

今日签到

点亮在社区的每一天
去签到