当前位置:网站首页>[pytorch] pytorch0.4.0 installation tutorial and GPU configuration collection (including test code)

[pytorch] pytorch0.4.0 installation tutorial and GPU configuration collection (including test code)

2022-06-13 07:43:00 neu_ eddata_ yjzhang

windows Installation under system pytorch0.4.0, stay linux When installing under the system, you only need to set the... In the command "win_amd64" Switch to ''linux_x86_64'' that will do .( Mostly , It depends on your system , But the method is the same )

Python3.6+pip install cpu edition

pip install http://download.pytorch.org/whl/cpu/torch-0.4.0-cp36-cp36m-win_amd64.whl

 Python3.6+pip install gpu edition
at present gpu Versioning support cuda8.0,cuda9.0 and cuda9.1, Please select the corresponding version to download and install , Do not execute the following three commands at the same time

pip install http://download.pytorch.org/whl/cu80/torch-0.4.0-cp36-cp36m-win_amd64.whl 
pip install http://download.pytorch.org/whl/cu90/torch-0.4.0-cp36-cp36m-win_amd64.whl
pip install http://download.pytorch.org/whl/cu91/torch-0.4.0-cp36-cp36m-win_amd64.whl

1. see pytorch Whether it exists and pytorch Version of

import torch
print(torch.__version__)

 2. see cuda Is it available

print(torch.cuda.is_available())

3. see cuda edition

print(torch.version.cuda)

  

4. View current working GPU 

print(torch.cuda.current_device())

 5. see gpu Number of

print(torch.cuda.device_count())

6. Set up work GPU

print(torch.cuda.current_device())
torch.cuda.set_device(1)
print(torch.cuda.current_device())

Some methods say that the following methods can also realize switching GPU But this sentence needs to be written in "import torch" Before .

os.environ["CUDA_VISIBLE_DEVICES"] = '0'

7. see gpu name , Device index defaults from 0 Start :

print(torch.cuda.get_device_name(0))
print(torch.cuda.get_device_name(1))

原网站

版权声明
本文为[neu_ eddata_ yjzhang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270547027837.html