在conda虚拟环境下安装TensorFlow 2.x GPU版

https://michael.blog.csdn.net/article/details/113175684

https://blog.csdn.net/weixin_44791964/article/details/109161493

若conda安装虚拟环境失败可能是conda设置了镜像,镜像停用了,导致创建失败

此时执行命令  conda config --remove-key channels 即可。

注意:cuda安装完成之后,重启电脑,否则在pycharm中GPU可能会显示Fasle

version = tf.__version__
gpu_ok = tf.test.is_gpu_available()
# tf.config.list_physical_devices('GPU') # 也可以
print("tf version:", version, "\nuse GPU", gpu_ok)
print(tf.test.is_built_with_cuda())

gpus = tf.config.list_physical_devices(device_type='GPU')  # []
cpus = tf.config.list_physical_devices(device_type='CPU')  # [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]
print(gpus)
print(cpus)


D:\anaconda\envs\tf2.2.0_gpu\python.exe D:/wlq/myProject/yolov4-tf2/yolov4-tf2/test.py
2021-05-17 15:03:59.443046: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
WARNING:tensorflow:From D:/wlq/myProject/yolov4-tf2/yolov4-tf2/test.py:14: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2021-05-17 15:04:10.355875: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2021-05-17 15:04:10.735354: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1b88a6ce2b0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-05-17 15:04:10.735572: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2021-05-17 15:04:10.762801: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-05-17 15:04:10.828252: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3090 computeCapability: 8.6
coreClock: 1.725GHz coreCount: 82 deviceMemorySize: 24.00GiB deviceMemoryBandwidth: 871.81GiB/s
2021-05-17 15:04:10.828409: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-05-17 15:04:10.850940: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-05-17 15:04:10.865972: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-05-17 15:04:10.870949: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-05-17 15:04:10.892760: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-05-17 15:04:10.907624: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-05-17 15:04:10.950424: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-05-17 15:04:10.950548: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2021-05-17 15:04:35.984464: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-05-17 15:04:35.984802: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108]      0 
2021-05-17 15:04:35.984978: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0:   N 
2021-05-17 15:04:36.006198: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/device:GPU:0 with 21831 MB memory) -> physical GPU (device: 0, name: GeForce RTX 3090, pci bus id: 0000:01:00.0, compute capability: 8.6)
2021-05-17 15:04:36.044705: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1b90960ef80 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2021-05-17 15:04:36.044823: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): GeForce RTX 3090, Compute Capability 8.6
2021-05-17 15:04:36.058513: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3090 computeCapability: 8.6
coreClock: 1.725GHz coreCount: 82 deviceMemorySize: 24.00GiB deviceMemoryBandwidth: 871.81GiB/s
2021-05-17 15:04:36.058746: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-05-17 15:04:36.058877: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-05-17 15:04:36.059005: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-05-17 15:04:36.059134: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-05-17 15:04:36.059263: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-05-17 15:04:36.059386: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-05-17 15:04:36.059509: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-05-17 15:04:36.059656: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
tf version: 2.2.0 
use GPU True
True
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]

Process finished with exit code 0
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值