经过三天的辛苦工作,我设法在CUDA支持下编译Tensorflow。 现在我不知道如何在 TFJS-NODE-GPU 项目中使用生成的二进制文件,即使我应该编译刚刚选择的 r1.9版本的Tensorflow,也不清楚
成功构建后,我将 bazel-bin / tensorflow / libtensorflow.so 复制到了项目的 node_module/@tensorflow/tfjs-node-gpu/build/Release/libtensorflow.so strong>(替换软件包随附的那个)。
现在,当我运行我的项目时,就可以识别我的GPU了,因为它以前具有较低的计算能力(5.0),因此不再被避免。
一切都很好,但是当我开始训练一个简单的模型时,我会收到此错误:
2019-05-14 01:31:07.855495: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2019-05-14 01:31:07.936251: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:897] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-05-14 01:31:07.937197: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1392] Found device 0 with properties:
name: GeForce 940M major: 5 minor: 0 memoryClockRate(GHz): 1.176
pciBusID: 0000:03:00.0
totalMemory: 1.96GiB freeMemory: 1.93GiB
2019-05-14 01:31:07.937219: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1471] Adding visible gpu devices: 0
2019-05-14 01:31:08.285047: I tensorflow/core/common_runtime/gpu/gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-05-14 01:31:08.285095: I tensorflow/core/common_runtime/gpu/gpu_device.cc:958] 0
2019-05-14 01:31:08.285102: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0: N
2019-05-14 01:31:08.285270: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1084] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1692 MB memory) -> physical GPU (device: 0, name: GeForce 940M, pci bus id: 0000:03:00.0, compute capability: 5.0)
(node:7718) Warning: N-API is an experimental feature and could change at any time.
Epoch 1 / 12
Error: Invalid TF_Status: 3
Message: NodeDef mentions attr 'Truncate' not in Op<name=Cast; signature=x:SrcT -> y:DstT; attr=SrcT:type; attr=DstT:type>; NodeDef: Cast = Cast[DstT=DT_INT32, SrcT=DT_FLOAT, Truncate=false](dummy_input). (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
at NodeJSKernelBackend.executeSingleOutput (/home/edu/Projects/boids/node_modules/@tensorflow/tfjs-node-gpu/dist/nodejs_kernel_backend.js:192:43)
at NodeJSKernelBackend.cast (/home/edu/Projects/boids/node_modules/@tensorflow/tfjs-node-gpu/dist/nodejs_kernel_backend.js:993:21)
at engine_1.ENGINE.runKernel.$x (/home/edu/Projects/boids/node_modules/@tensorflow/tfjs-core/dist/ops/array_ops.js:385:74)
at /home/edu/Projects/boids/node_modules/@tensorflow/tfjs-core/dist/engine.js:384:26
at Engine.scopedRun (/home/edu/Projects/boids/node_modules/@tensorflow/tfjs-core/dist/engine.js:338:23)
at Engine.runKernel (/home/edu/Projects/boids/node_modules/@tensorflow/tfjs-core/dist/engine.js:382:14)
at cast_ (/home/edu/Projects/boids/node_modules/@tensorflow/tfjs-core/dist/ops/array_ops.js:385:28)
at Object.cast (/home/edu/Projects/boids/node_modules/@tensorflow/tfjs-core/dist/ops/operation.js:46:29)
at Tensor.asType (/home/edu/Projects/boids/node_modules/@tensorflow/tfjs-core/dist/tensor.js:335:26)
at Tensor.toInt (/home/edu/Projects/boids/node_modules/@tensorflow/tfjs-core/dist/tensor.js:443:21)
我想知道我是否正在编译适用于TFJS-NODE-GPU的Tensorflow版本,以及如何在我的项目中使用编译后的二进制文件。
谢谢!
以下是与我的系统以及如何编译Tensorflow有关的所有信息:
系统
Linux Fedora 30(i7、12G Ram) GPU GeForce 940m具有计算能力5.0 运行NVIDIA驱动程序418.74。 CUDA 10和CuDNN 7
Tensorflow构建
我使用以下bazel参数从分支“ r1.9”编译了tensorflow:
bazel build --local_resources 2048,1,1.0 --config = monolithic --config = cuda --action_env PATH =“ $ PATH” // tensorflow / tools / lib_package:libtensorflow --verbose_failures
正如TFJS存储库中所建议的那样,我刚刚添加了--local_resources来限制内存/ cpu的使用(因为我正在docker容器内构建)和cuda支持。
Tensorflow ./configure
-Jemalloc as malloc support
-No Google Cloud Platform support
-No Hadoop File System support
-No Amazon S3 File System support
-No Apache Kafka Platform support
-XLA JIT support
-No GDR support
-No VERBS support
-No OpenCL SYCL support
-CUDA support: Yes
-CUDA SDK version: 10.0
-cuDNN version 7.0 (default, detected)
-No TensorRT support
-Compute capability: 5.0
-CUDA compiler [nvcc]
-No MPI support
-Optimization flags [-march=native] (Default)
此外,我使用docker容器(使用nvidia-docker2)进行构建,默认情况下几乎所有依赖项都在其中满足。