GPU/python environment configuration and verification.
(1) Install NVIDIA GPU driver and CUDA toolkit for GPU accelerated instances: https://support.huaweicloud.com/usermanual-ecs/zh-cn_topic_0149470468.html#ZH-CN_TOPIC_0149470468__section1034245773916
(2) Huawei Cloud Linux Server Deployment TensorFlow-gpu Guide:https://www.cnblogs.com/zxyza/p/10535939.html
(3) Install Anaconda3 on Ubuntu: https://www.jianshu.com/p/d9fb4e65483c
(4) Add environment variables: vim ~/.bashrc
export PATH="/root/anaconda3/bin:$PATH"export PATH=/usr/local/cuda/bin{PATH:+:{PATH}}export LD_LIBRARY_PATH=/usr/local/cuda/lib64{LD_LIBRARY_PATH:+:{LD_LIBRARY_PATH}}export CUDA_HOME=/usr/local/cuda
(5)source ~/.bashrc
(6) Create a virtual environment:
conda create -n py37 python=3.7
Enter the environment
source activate py37
conda activate py37
Exit the environment
source deactivate
conda deactivate
(7)source activate py37
(8) Install tensorflow-gpu: pip install tensorflow-gpu==1.13.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
(9) Test:
import tensorflow as tf
import os
print('GPU>>>>>>', tf.test.is_gpu_available())
a = tf.constant(2.0)
b = tf.constant(4.0)
print(a + b)
(10) result:
GPU>>>>>> True
Tensor("add:0", shape=(), dtype=float32)
(11) Different versions of torch installation:
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.0
conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.1
The above command is too slow to install the wife directly, you can speed up the download by changing the conda source.
# Modify conda configuration
vim .condarc
# Add Tsinghua source in configuration clock
channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
- default
show_channel_urls:true
# Install pytorch and the corresponding version of cudatoolkit
conda install pytorch=1.4.0 torchvision cudatoolkit=10.1
Recommended Posts