为了解决 torch.cuda.is_avalibale()
安装
472.12-desktop-win8-win7-64bit-international-whql.exe
cuda_11.5.0_496.13_win10.exe
torch-1.11.0.dev20211115+cu113-cp37-cp37m-win_amd64.whl
莫名的能用了
C:\Users\Administrator>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_Sep_13_20:11:50_Pacific_Daylight_Time_2021
Cuda compilation tools, release 11.5, V11.5.50
Build cuda_11.5.r11.5/compiler.30411180_0
C:\Users\Administrator>
(tf26) C:\Users\Administrator>pip list |grep cu
pycuda 2021.1
torch 1.11.0.dev20211115+cu113
(tf26) C:\Users\Administrator>pip list |grep tensor
tensorboard 2.7.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.0
tensorflow 2.7.0
tensorflow-gpu 2.7.0
tensorflow-io-gcs-filesystem 0.21.0
Python 3.7.11 (default, Jul 27 2021, 09:42:29) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.29.0 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 7.29.0
Python 3.7.11 (default, Jul 27 2021, 09:42:29) [MSC v.1916 64 bit (AMD64)] on win32
import torch
import torch
torch.cuda.is_available()
Out[4]: True
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
# Creates a graph.
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print(sess.run(c))
WARNING:tensorflow:From C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\compat\v2_compat.py:111: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: NVIDIA GeForce GTX 1060 6GB, pci bus id: 0000:07:00.0, compute capability: 6.1
[[22. 28.]
[49. 64.]]