So technically even with those errors, it is finding my gpu and using CUDA cores. However, I’m still reasonably sure it’s not working 100% as it should, hence the errors. It’s also getting this NUMA I printout when I run some other code:
2024-02-09 21:52:43.747526: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
You have CUDA CUdnn and Tensorrt installed properly ?
So I don’t have them installed. From what I read tensorRT is an optional library (do you agree?), so I haven’t been trying to use it yet, but I think I probably will in the future. As for CUDA and cuDNN, I’m a little confused on the installation documentation. From what I have read as of tensorflow 2.15 using ‘pip install tensorflow[and-cuda]’ will install the necessary dependencies from CUDA and cuDNN for me, so I don’t think I need to install them separately. Clearly it’s not perfect cuz it gave errors. It installing the dependencies sounds like a new thing, and most of the documentation has the old way of installing CUDA and cuDNN separately/manually. (I might totally be wrong on all of this)
As for conda, I haven’t been using it, not really for any particular reason, but because I didn’t think it was a requirement. Is it a requirement for this to work?
I will try making a new installation on Monday with conda. Then I’ll test the code you gave me.
This is the example I’ve been using and it’s printouts:
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.utils import to_categorical
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
Generate some random classification data
X, y = make_classification(n_samples=10000, n_features=20, n_classes=2, random_state=42)
Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
Convert labels to one-hot encoding
y_train = to_categorical(y_train)
y_test = to_categorical(y_test)
Define a simple Keras model
model = Sequential([
Dense(64, activation=‘relu’, input_shape=(20,)),
Dense(32, activation=‘relu’),
Dense(2, activation=‘softmax’)
])
Compile the model
model.compile(optimizer=Adam(), loss=‘categorical_crossentropy’, metrics=[‘accuracy’])
Check if GPU is available and if it’s using CUDA cores
physical_devices = tf.config.list_physical_devices(‘GPU’)
if len(physical_devices) > 0:
print(“GPU available. Training on GPU.”)
else:
print(“No GPU available. Training on CPU.”)
Train the model
history = model.fit(X_train, y_train, epochs=2, batch_size=64, validation_data=(X_test, y_test))
Evaluate the model
test_loss, test_acc = model.evaluate(X_test, y_test)
print(“Test Accuracy:”, test_acc)
2024-02-09 21:52:40.810870: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-02-09 21:52:40.811052: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-02-09 21:52:40.825636: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-02-09 21:52:40.966027: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-02-09 21:52:41.886546: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-02-09 21:52:43.747526: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-02-09 21:52:44.098519: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-02-09 21:52:44.098574: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-02-09 21:52:44.103297: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-02-09 21:52:44.103341: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-02-09 21:52:44.103357: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-02-09 21:52:44.292290: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-02-09 21:52:44.292343: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-02-09 21:52:44.292348: I tensorflow/core/common_runtime/gpu/gpu_device.cc:2022] Could not identify NUMA node of platform GPU id 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2024-02-09 21:52:44.292370: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-02-09 21:52:44.292567: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1929] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 2249 MB memory: → device: 0, name: NVIDIA T600 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 7.5
GPU available. Training on GPU.
Epoch 1/2
2024-02-09 21:52:45.014338: I external/local_tsl/tsl/platform/default/subprocess.cc:304] Start cannot spawn child process: No such file or directory
2024-02-09 21:52:45.087930: I external/local_xla/xla/service/service.cc:168] XLA service 0x7f2caa859120 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2024-02-09 21:52:45.087960: I external/local_xla/xla/service/service.cc:176] StreamExecutor device (0): NVIDIA T600 Laptop GPU, Compute Capability 7.5
2024-02-09 21:52:45.108520: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:269] disabling MLIR crash reproducer, set env var MLIR_CRASH_REPRODUCER_DIRECTORY
to enable.
2024-02-09 21:52:45.158805: I external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:454] Loaded cuDNN version 8904
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1707537165.268011 29229 device_compiler.h:186] Compiled cluster using XLA! This line is logged at most once for the lifetime of the process.
125/125 [==============================] - 2s 7ms/step - loss: 0.3940 - accuracy: 0.8370 - val_loss: 0.2797 - val_accuracy: 0.8945
Epoch 2/2
125/125 [==============================] - 1s 7ms/step - loss: 0.2872 - accuracy: 0.8934 - val_loss: 0.2653 - val_accuracy: 0.8985
63/63 [==============================] - 0s 5ms/step - loss: 0.2653 - accuracy: 0.8985
Test Accuracy: 0.8985000252723694
Here are all of the libraries I currently have installed:
pip list
Package Version
absl-py 2.1.0
asttokens 2.4.1
astunparse 1.6.3
blinker 1.4
borb 2.1.21
cachetools 5.3.2
certifi 2024.2.2
cffi 1.16.0
charset-normalizer 3.3.2
comm 0.2.1
command-not-found 0.3
contourpy 1.2.0
cryptography 42.0.2
cycler 0.12.1
dbus-python 1.2.18
debugpy 1.8.0
decorator 5.1.1
distro 1.7.0
distro-info 1.1+ubuntu0.2
exceptiongroup 1.2.0
executing 2.0.1
flatbuffers 23.5.26
fonttools 4.48.1
gast 0.5.4
google-auth 2.27.0
google-auth-oauthlib 1.2.0
google-pasta 0.2.0
grpcio 1.60.1
h5py 3.10.0
httplib2 0.20.2
idna 3.6
importlib-metadata 4.6.4
ipykernel 6.29.1
ipython 8.21.0
jedi 0.19.1
jeepney 0.7.1
joblib 1.3.2
jupyter_client 8.6.0
jupyter_core 5.7.1
keras 2.15.0
keyring 23.5.0
kiwisolver 1.4.5
launchpadlib 1.10.16
lazr.restfulclient 0.14.4
lazr.uri 1.0.6
libclang 16.0.6
lxml 5.1.0
Markdown 3.5.2
MarkupSafe 2.1.5
matplotlib 3.8.2
matplotlib-inline 0.1.6
ml-dtypes 0.2.0
more-itertools 8.10.0
nest-asyncio 1.6.0
netifaces 0.11.0
numpy 1.26.4
nvidia-cublas-cu12 12.2.5.6
nvidia-cuda-cupti-cu12 12.2.142
nvidia-cuda-nvcc-cu12 12.2.140
nvidia-cuda-nvrtc-cu12 12.2.140
nvidia-cuda-runtime-cu12 12.2.140
nvidia-cudnn-cu12 8.9.4.25
nvidia-cufft-cu12 11.0.8.103
nvidia-curand-cu12 10.3.3.141
nvidia-cusolver-cu12 11.5.2.141
nvidia-cusparse-cu12 12.1.2.141
nvidia-nccl-cu12 2.16.5
nvidia-nvjitlink-cu12 12.2.140
oauthlib 3.2.0
opt-einsum 3.3.0
packaging 23.2
pandas 2.2.0
parso 0.8.3
patsy 0.5.6
pexpect 4.9.0
pillow 10.2.0
pip 24.0
platformdirs 4.2.0
prompt-toolkit 3.0.43
protobuf 4.23.4
psutil 5.9.8
ptyprocess 0.7.0
pure-eval 0.2.2
pyasn1 0.5.1
pyasn1-modules 0.3.0
pycparser 2.21
Pygments 2.17.2
PyGObject 3.42.1
PyJWT 2.3.0
pyparsing 2.4.7
pypng 0.20220715.0
python-apt 2.4.0+ubuntu2
python-barcode 0.15.1
python-dateutil 2.8.2
pytz 2024.1
PyYAML 5.4.1
pyzmq 25.1.2
qrcode 7.4.2
requests 2.31.0
requests-oauthlib 1.3.1
rsa 4.9
scikit-learn 1.4.0
scipy 1.12.0
seaborn 0.13.2
SecretStorage 3.3.1
setuptools 59.6.0
six 1.16.0
stack-data 0.6.3
statsmodels 0.14.1
systemd-python 234
tensorboard 2.15.1
tensorboard-data-server 0.7.2
tensorflow 2.15.0.post1
tensorflow-estimator 2.15.0
tensorflow-io-gcs-filesystem 0.36.0
termcolor 2.4.0
threadpoolctl 3.2.0
tornado 6.4
traitlets 5.14.1
typing_extensions 4.9.0
tzdata 2023.4
ubuntu-advantage-tools 8001
ufw 0.36.1
unattended-upgrades 0.1
urllib3 2.2.0
wadllib 1.3.6
wcwidth 0.2.13
Werkzeug 3.0.1
wheel 0.37.1
wrapt 1.14.1
zipp 1.0.0