Anaconda installs pytoch and Tensorflow

Posted by tech603 on Thu, 07 Oct 2021 22:54:37 +0200

catalogue

Python CPU version installation:

one   Anaconda installation:

two   Python environment configuration

two point one   Configure mirror source

2.2 create a new environment:

2.3 activation environment

2.4. Install pytorch (tensorflow) and corresponding Libraries

2.5 problems

Tensorflow GPU version installation

1 cuda version determination

1.1 check cuda and NVIDIA version numbers

1.2 view NVIDIA version number

1.3 view the corresponding versions of tensorflow and cuda

1.3 download cuda (select the following according to your computer version, otherwise there will be version mismatch)

2. Install cuda

2.1 when downloading and installing, only user-defined installation is selected, and cuda is selected

2.2 test after installation (win+R input cmd)

2.3 configure the environment variables and add the following three variables to the path

3 install the corresponding version of cudnn (e.g. cudnn 6)

4. Install tensorflow GPU

four point one   anaconda create environment (see cpu installation for environment configuration)

4.2 activate new environment

4.3 installing tensorflow gpu

4.4 test code

5 question:

Pytorch GPU version installation  

1.anaconda creates a new environment

2. Install pytorch

3. Test

Python CPU version installation:

one   Anaconda installation:

Official website: https://www.anaconda.com/products/individual#download

Note: the installation process can automatically add the path to the environment variable without selecting

two   Python environment configuration

two point one   Configure mirror source

  • Method 1: through the. condarc file:
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/

show_channel_urls: true

ssl_verify: true

You can copy the file directly and put it in C:\Users \ your user name   Under folder

  • Method 2: add by command
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

2.2 create a new environment:

#[multiple environments can be created with the same command]
conda create -n name(tensorflow2) python=python Version (3).7.4)

#Remove environment
conda remove -n name(Environment name) --all 


#Activate environment
activate tensorflow2(deactivate)

2.3 activation environment

The installation needs to be carried out in the corresponding environment

#Activate environment
activate tensorflow2(deactivate)

2.4. Install pytorch (tensorflow) and corresponding Libraries

#Install python command
conda install python=python Version number

#Install pytorch cpu version
conda install pytorch torchvision cpuonly (-c pytorch)----The installation address in brackets is the official website

#Modify pytorch version
conda install pytorch=1.4.0 -c soumith

#Install tensorflow cpu version
pip install --upgrade --ignore-installed tensorflow

#Installing jupyter lab
conda install jupyterlab

#Open Jupiter lab
jupyter lab

#numpy installation
conda install numpy 

2.5 problems

  • Problem encountered with OpenSSL: DLL load failed

Solution: libssl-1_1-x64.dll is the date of this year, change the name, copy the same name from different locations to the location of libssl-1_1-x64.dll, and then reinstall

  • HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out

Solution: add - i domestic image after the installation command

Tensorflow GPU version installation

1 cuda version determination

1.1 check cuda and NVIDIA version numbers

1.2 view NVIDIA version number

  1. Desktop -- > right click NVIDIA management panel
  2. Select the help -- > system information -- > component

The cuda version supported by the computer is 8.0

1.3 view the corresponding versions of tensorflow and cuda

1.3 download cuda (select the following according to your computer version, otherwise there will be version mismatch)

website: CUDA Toolkit 8.0 - Feb 2017 | NVIDIA Developer

2. Install cuda

Reference blog: Installing cuda8.0 under Windows - chenzhen0530 - blog Garden

2.1 when downloading and installing, only user-defined installation is selected, and cuda is selected

According to the default path, create the same folder in other drive letters for the installation path

2.2 test after installation (win+R input cmd)

#cuda version can be viewed
nvcc -V  

2.3 configure the environment variables and add the following three variables to the path

D:\CUDAFILE\NVDIA GPU Computing Toolkit\CUDA\v8.0\bin

D:\CUDAFILE\NVDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp

D:\CUDAFILE\NVDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64

3 install the corresponding version of cudnn (e.g. cudnn 6)

After downloading, unzip a folder named CUDA; copy the files under this folder to CUDA installed in the previous step; pay attention to the corresponding folder;

./cuda/bin/**.dll Copy to ./NVIDIA GPU Computing Tookit/CUDA/v8.0/bin/
 
./cuda/include/**.dll Copy to ./NVIDIA GPU Computing Tookit/CUDA/v8.0/include/

./cuda/lib/x64/**.dll Copy to ./NVIDIA GPU Computing Tookit/CUDA/v8.0/lib/x64/

4. Install tensorflow GPU

four point one   anaconda create environment (see cpu installation for environment configuration)

conda create -n name(tensorflow-gpu) python=python Version (3).6.0)

4.2 activate new environment

activate tensorflow-gpu

4.3 installing tensorflow gpu

conda/pip install tensorflow-gpu==1.4.0

4.4 test code

import tensorflow as tf 

hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() 

print(sess.run(hello))

Reference blog: win10+NVIDIA GTX 960M+CUDA 8.0+cudnn6.0 installation _weisongzhaocsdn blog

5 question:

Could not find 'cudart64_100.dll

Solution:

1. Version mismatch - Download and install again

2. cuda is not configured in the environment variable --- configure the environment variable  

Pytorch GPU version installation  

The remaining steps are to install the local cuda

1.anaconda creates a new environment

2. Install pytorch

(cudnn and cuda have been installed before installing tensorflow, so you can install pytorch directly)

Official website: Previous PyTorch Versions | PyTorch

The installed version is pytorch 0.4.1 cuda8.0

# Installation command
conda install pytorch=0.4.1 cuda80 

3. Test

# If you print True, the installation is successful
import torch print(torch.cuda.is_available()) 

Topics: Python TensorFlow Pytorch