Tensorflow rechnet immer auf CPU

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
Marvin93
User
Beiträge: 38
Registriert: Samstag 4. Mai 2019, 15:16

Hallo,

mein Laptop trainiert die neuronalen Netze immer auf der CPU und ich hab keine Ahnung was ich noch machen soll. Bin die Anleitung hier durchgegangen:
https://docs.nvidia.com/cuda/cuda-insta ... t-windows/

Habe dann noch stundenlang auf google gesucht und youtube videos geguckt usw. und es klappt einfach nicht. Ich bin jetzt immerhin endlich soweit gekommen, dass ich den ganzen Installationsprozess bis zum Ende durchführen konnte und auch diese Sample Dateien ausführen kann. Wenn ich folgendes ausführe (irgendwo gefunden und ein bisschen angepasst, um zu checken, ob alles funktioniert):

Code: Alles auswählen

import tensorflow as tf

print(tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True)))

with tf.device('/gpu:0'):
	a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
	b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
	c = tf.matmul(a, b)

     # Launch the graph in a session.
with tf.compat.v1.Session() as ses:

    # Build a graph.
    a = tf.constant(5.0)
    b = tf.constant(6.0)
    c = a * b   
    # Evaluate the tensor `c`.
    print(ses.run(c))
Wird mir das ausgegeben:

Code: Alles auswählen

2021-01-05 00:53:45.462076: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-01-05 00:53:45.464277: I tensorflow/core/common_runtime/direct_session.cc:360] Device mapping: no known devices.
<tensorflow.python.client.session.Session object at 0x000001A7B5E3FF48>
30.0

Ich hab wirklich keine Ahnung was ich noch machen soll. CUDA scheint wohl richtig installiert zu sein. Zumindest, wenn ich diversen Anleitungen vertrauen kann. Ich habe die Datei "deviceQuery.exe" ausgeführt und folgendes Ergebnis bekommen:

Code: Alles auswählen

C:\Program Files\NVIDIA Corporation\NVSMI>nvidia-smi.exe
Tue Jan  5 00:40:07 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.89       Driver Version: 460.89       CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 960M   WDDM  | 00000000:01:00.0  On |                  N/A |
| N/A   44C    P8    N/A /  N/A |    309MiB /  2048MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1256    C+G   Insufficient Permissions        N/A      |
|    0   N/A  N/A      1956    C+G   ...ub.ThreadedWaitDialog.exe    N/A      |
|    0   N/A  N/A     16156    C+G   ...ty\Common7\IDE\devenv.exe    N/A      |
+-----------------------------------------------------------------------------+

C:\Program Files\NVIDIA Corporation\NVSMI>cd C:\ProgramData\NVIDIA Corporation\CUDA Samples\v11.2\bin\win64\Debug

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v11.2\bin\win64\Debug>deviceQuery.exe
deviceQuery.exe Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 960M"
  CUDA Driver Version / Runtime Version          11.2 / 11.2
  CUDA Capability Major/Minor version number:    5.0
  Total amount of global memory:                 2048 MBytes (2147483648 bytes)
  ( 5) Multiprocessors, (128) CUDA Cores/MP:     640 CUDA Cores
  GPU Max Clock rate:                            1176 MHz (1.18 GHz)
  Memory Clock rate:                             2505 Mhz
  Memory Bus Width:                              128-bit
  L2 Cache Size:                                 2097152 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total shared memory per multiprocessor:        65536 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 4 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  CUDA Device Driver Mode (TCC or WDDM):         WDDM (Windows Display Driver Model)
  Device supports Unified Addressing (UVA):      Yes
  Device supports Managed Memory:                Yes
  Device supports Compute Preemption:            No
  Supports Cooperative Kernel Launch:            No
  Supports MultiDevice Co-op Kernel Launch:      No
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.2, CUDA Runtime Version = 11.2, NumDevs = 1
Result = PASS

Hat jemand eine Idee woran das liegen könnte?

Gruß
Marvin
Antworten