写在前面:
conda 会覆盖pip安装的包,pip 不会覆盖conda的包。
尽量避免混用,如果必须要混用,先用conda再用pip。
conda
conda config --set show_channel_urls yes
conda info --env
conda info
conda --version
conda install package_name1 package_name2 package_name3
conda list
conda env list
conda env export > environment.yaml
conda env create -f environment.yaml
conda activate pytorch
conda remove -n your_env_name --all
conda create --name tensorflow python=3.8
conda create -name your_env_name python=version_no anaconda ##(如果末尾不添加anaconda命令,则该虚拟环境只有python,没有其他包)
conda search tensorflow-gpu
conda list
conda clean -i
conda search cudatoolkit
conda install cudatoolkit=8.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
conda install cudnn=7.0.5 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
conda install --yes --file requirements.txt
conda 配置镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
docker
docker run --gpus all --name="xiao-pycharm" -it -p 1888:8888 -p 1006:6006 -v /sda1/xiao/xiehongyan:/home python3.8_torch1.8.2:1.0 /bin/bash
--ipc=host
--shm-size="15g"
--ulimit memlock=-1
--ulimit stack=67108864
memlock=-1表示无限制内存锁定,stack=67108864表示栈的最大大小为64MB
docker run --gpus all --name="xiao_ubuntu20.04" -it -p 2223:22 -p 6007:2007 -p 6008:2008 -p 2006:6006 -v /sda1/xiao/xiao_ubuntu20.04:/home /sda1/xiao/Datasets:/home 3918f26174ea /bin/bash
docker run --gpus all --name="xiao-ultralytics" -it -p 11741:22 -p 1889:8888 -p 2006:6006 -p 8080:80 -v /mnt/data/xiao/pycharm-spqce/ultralytics230614:/home --ipc=host --ulimit memlock=-1 ultralytics/ultralytics:latest /bin/bash
docker attach test
sudo service docker start
sudo service docker stop
sudo service docker restart
systemctl restart docker
pip
pip freeze > requirements.txt
pip install opencv-python (cv2)
pip install tensorflow==2.6.0
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
pip config set install.trusted-host mirrors.aliyun.com
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
pip临时换源:
pip install xxx -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
tensorboard
使用绝对路径: tensorboard --logdir=D:\Python\pytorchLearn\learn\logs
!tensorboard --logdir=train-logs
!tensorboard --logdir /home/train-logs --port 6006 --bind_all
ubuntu
uname -a
pwd
bash Anaconda3-2022.05-Linux-x86_64.sh
htop
free -m
nvidia-smi
sudo chown -R apr:user /var/lib/docker
检查pytorch与cuda的安装
import torch
import sys
print(sys.version)
print(torch.__version__)
print(torch.cuda.is_available())
检查tensorflow与cuda的安装import sys
import sys
print(sys.version)
import tensorflow as tf
tf.autograph.set_verbosity(0)
physical_devices = tf.config.experimental.list_physical_devices('GPU')
print(physical_devices)
config = tf.config.experimental.set_memory_growth(physical_devices[0], True)
import tensorflow as tf
print(tf.test.is_gpu_available())
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
jupyter
jupyter notebook --port 1011 #指定1011端口启动
nohup python -u main.py > test.out 2>&1 &
tail -f test.out