import tensorflow as tf
print(tf.test.is_gpu_available())
一开始想看看安装的tensorflow-gpu是否能运行,但是运行半天,没有得到任何结果,程序结束后终端只返回了Process finished with exit code -1073741819 (0xC0000005)。
解决办法:
更改h5py版本
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple h5py==2.9.0
然后再次运行代码,得到结果:
2023-04-23 20:12:32.624224: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2023-04-23 20:12:32.626467: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll
2023-04-23 20:12:33.666198: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
name: NVIDIA GeForce RTX 2060 major: 7 minor: 5 memoryClockRate(GHz): 1.2
pciBusID: 0000:01:00.0
2023-04-23 20:12:33.666411: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
2023-04-23 20:12:33.666572: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
2023-04-23 20:12:34.145105: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:
2023-04-23 20:12:34.145272: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0
2023-04-23 20:12:34.145362: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N
2023-04-23 20:12:34.145582: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/device:GPU:0 with 4724 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce RTX 2060, pci bus id: 0000:01:00.0, compute capability: 7.5)
TrueProcess finished with exit code 0