【问题标题】:Trouble installing Keras GPU in R - invalid version specification在 R 中安装 Keras GPU 时遇到问题 - 版本规范无效
【发布时间】:2021-03-09 02:39:35
【问题描述】:

我已按照许多指南尝试在我的新笔记本电脑上安装带有 GPU 的 Keras。一些细节:

  • Windows 10 64 位
  • Nvidia T1000 GPU
  • R 版本 4.0.4
  • 我已关注 this 的软件依赖项,包括 CUDA 11.2 和 cuDNN 8.1.1。根据 cuDNN 站点,这是 CUDA 11.2 的正确 cuDNN。我还更新了驱动程序。
  • 我已将 cuDNN 文件从 bin、include 和 lib 复制到 NVIDIA GPU Computing Toolkit 中它们各自的文件夹中。
  • 我还将这些文件夹和 cuDNN 文件夹添加到我的 PATH 环境变量中。

这是我的 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"    

我尝试过指南 hereherehere

我已经成功运行了:

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 并且安装正常。如果我使用 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:

【问题讨论】:

  • 同样的结果,不幸的是。但是,基于this 以及上面的最终代码块包含Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 的事实,我认为即使keras::install_keras() 没有,GPU 安装也有可能?

标签: r tensorflow keras


【解决方案1】:

我认为问题出在最新的 R keras 包中。我通过使用降级 keras 包

require(devtools)
install_version("keras", version = "2.3.0.0")

然后可以正确安装keras

【讨论】:

    猜你喜欢
    • 2019-11-04
    • 1970-01-01
    • 2018-09-24
    • 1970-01-01
    • 2020-11-11
    • 2019-03-01
    • 2022-08-24
    • 2019-08-21
    • 1970-01-01
    相关资源
    最近更新 更多