我遵循了许多指南,尝试在我的新笔记本上安装带有GPU的Keras。一些细节:
以下是我的CUDA bin文件夹中的文件(我尝试过安装CUDA 10、10.1和11.2):
list.files("C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.2\\bin\\")
[1] "bin2c.exe" "compute-sanitizer.bat" "crt" "cu++filt.exe"
[5] "cublas64_10.dll" "cublas64_100.dll" "cublas64_11.dll" "cublasLt64_10.dll"
[9] "cublasLt64_11.dll" "cuda-memcheck.exe" "cudafe++.exe" "cudart32_110.dll"
[13] "cudart64_100.dll" "cudart64_101.dll" "cudart64_110.dll" "cudnn_adv_infer64_8.dll"
[17] "cudnn_adv_train64_8.dll" "cudnn_cnn_infer64_8.dll" "cudnn_cnn_train64_8.dll" "cudnn_ops_infer64_8.dll"
[21] "cudnn_ops_train64_8.dll" "cudnn64_8.dll" "cufft64_10.dll" "cufftw64_10.dll"
[25] "cuinj64_112.dll" "cuobjdump.exe" "curand64_10.dll" "cusolver64_10.dll"
[29] "cusolverMg64_11.dll" "cusparse64_10.dll" "cusparse64_11.dll" "fatbinary.exe"
[33] "nppc64_11.dll" "nppial64_11.dll" "nppicc64_11.dll" "nppidei64_11.dll"
[37] "nppif64_11.dll" "nppig64_11.dll" "nppim64_11.dll" "nppist64_11.dll"
[41] "nppisu64_11.dll" "nppitc64_11.dll" "npps64_11.dll" "nvblas64_11.dll"
[45] "nvcc.exe" "nvcc.profile" "nvdisasm.exe" "nvjpeg64_11.dll"
[49] "nvlink.exe" "nvprof.exe" "nvprune.exe" "nvrtc-builtins64_112.dll"
[53] "nvrtc-prev" "nvrtc64_112_0.dll" "nvvp.bat" "ptxas.exe" 我成功地跑了:
tensorflow::install_tensorflow(gpu = TRUE)
reticulate::use_condaenv("r-tensorflow")
tf$constant("hello")然后我收到消息:
2021-03-08 20:54:50.917771: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-03-08 20:55:00.607511: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-03-08 20:55:02.286421: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: Quadro T1000 computeCapability: 7.5
coreClock: 1.53GHz coreCount: 14 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 178.84GiB/s
2021-03-08 20:55:02.286702: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-03-08 20:55:02.657731: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-03-08 20:55:03.052477: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-03-08 20:55:03.230033: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-03-08 20:55:03.526342: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-03-08 20:55:03.920362: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-03-08 20:55:03.930081: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-03-08 20:55:04.440275: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2021-03-08 20:55:04.440969: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2021-03-08 20:55:04.450175: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x211965ca050 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-03-08 20:55:04.450424: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2021-03-08 20:55:04.450851: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: Quadro T1000 computeCapability: 7.5
coreClock: 1.53GHz coreCount: 14 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 178.84GiB/s
2021-03-08 20:55:04.451300: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-03-08 20:55:04.451552: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-03-08 20:55:04.451803: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-03-08 20:55:04.451982: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-03-08 20:55:04.452149: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-03-08 20:55:04.452363: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-03-08 20:55:04.452502: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-03-08 20:55:04.452708: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2021-03-08 20:55:05.372995: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-03-08 20:55:05.373218: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108] 0
2021-03-08 20:55:05.373358: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0: N
2021-03-08 20:55:05.373600: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 2917 MB memory) -> physical GPU (device: 0, name: Quadro T1000, pci bus id: 0000:01:00.0, compute capability: 7.5)
2021-03-08 20:55:05.376339: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x211965dcad0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2021-03-08 20:55:05.376629: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Quadro T1000, Compute Capability 7.5
tf.Tensor(b'hello', shape=(), dtype=string)但是,如果我试着
keras::install_keras(tensorflow = "gpu")在新的RStudio会话中,我得到
Error: invalid version specification但随后我尝试从命令行运行conda install -c anaconda keras-gpu,并安装了OK。如果我使用IMDB数据集在Keras上运行测试,那么它似乎运行得很好:
library(keras)
model <- keras_model_sequential() %>%
layer_dense(units = 16, activation = "relu", input_shape = c(10000)) %>%
layer_dense(units = 16, activation = "relu") %>%
layer_dense(units = 1, activation = "sigmoid")返回:
2021-03-08 21:51:14.726620: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-03-08 21:51:16.456659: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: Quadro T1000 computeCapability: 7.5
coreClock: 1.53GHz coreCount: 14 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 178.84GiB/s
2021-03-08 21:51:16.456844: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-03-08 21:51:16.460816: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-03-08 21:51:16.465207: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-03-08 21:51:16.466657: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-03-08 21:51:16.470899: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-03-08 21:51:16.473512: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-03-08 21:51:16.482108: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-03-08 21:51:16.482375: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2021-03-08 21:51:16.484124: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2021-03-08 21:51:16.495226: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1edbf69c2d0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-03-08 21:51:16.495403: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2021-03-08 21:51:16.495774: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: Quadro T1000 computeCapability: 7.5
coreClock: 1.53GHz coreCount: 14 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 178.84GiB/s
2021-03-08 21:51:16.496029: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-03-08 21:51:16.496131: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-03-08 21:51:16.496247: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-03-08 21:51:16.496347: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-03-08 21:51:16.496438: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-03-08 21:51:16.496540: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-03-08 21:51:16.496703: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-03-08 21:51:16.496866: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2021-03-08 21:51:17.007480: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-03-08 21:51:17.007586: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108] 0
2021-03-08 21:51:17.007676: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0: N
2021-03-08 21:51:17.007896: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 2917 MB memory) -> physical GPU (device: 0, name: Quadro T1000, pci bus id: 0000:01:00.0, compute capability: 7.5)
2021-03-08 21:51:17.011318: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1edbf6afdd0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2021-03-08 21:51:17.011464: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Quadro T1000, Compute Capability 7.5任何帮助都非常感谢:upside_down_face:
发布于 2021-04-26 20:29:10
我认为问题在最新的R方案中。我通过使用
require(devtools)
install_version("keras", version = "2.3.0.0")然后就可以正确安装keras了。
https://stackoverflow.com/questions/66540020
复制相似问题