Test with real GPU

This commit is contained in:
Anthony Wang 2021-12-13 18:38:45 -06:00
parent b92369bd81
commit 8f2bf9742d
Signed by: a
GPG key ID: BC96B00AEC5F2D76
2 changed files with 155 additions and 83 deletions

File diff suppressed because one or more lines are too long

View file

@ -35,7 +35,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 1,
"metadata": { "metadata": {
"_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
"_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5" "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5"
@ -62,18 +62,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stderr",
"output_type": "stream",
"text": [
"2021-12-13 18:32:23.674213: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/lib:\n",
"2021-12-13 18:32:23.674228: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.\n"
]
}
],
"source": [ "source": [
"import tensorflow as tf" "import tensorflow as tf"
] ]
@ -87,19 +78,17 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 3,
"metadata": { "metadata": {
"_cell_guid": "79c7e3d0-c299-4dcb-8224-4455121ee9b0", "_cell_guid": "79c7e3d0-c299-4dcb-8224-4455121ee9b0",
"_uuid": "d629ff2d2480ee46fbb7e2d37f6b5fab8052498a" "_uuid": "d629ff2d2480ee46fbb7e2d37f6b5fab8052498a"
}, },
"outputs": [ "outputs": [
{ {
"name": "stderr", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"2021-12-13 18:32:29.435339: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/lib:\n", "Name: /physical_device:GPU:0 Type: GPU\n"
"2021-12-13 18:32:29.435356: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)\n",
"2021-12-13 18:32:29.435368: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (exozyme): /proc/driver/nvidia/version does not exist\n"
] ]
} }
], ],
@ -119,22 +108,43 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"ename": "Error", "name": "stderr",
"evalue": "Session cannot generate requests", "output_type": "stream",
"output_type": "error", "text": [
"traceback": [ "2021-12-13 18:36:17.947416: 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: SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA\n",
"Error: Session cannot generate requests", "To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
"at w.executeCodeCell (/home/ta180m/.vscode-oss/extensions/ms-toolsai.jupyter-2021.10.100/out/client/extension.js:52:302205)", "2021-12-13 18:36:17.948346: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1510] Created device /device:GPU:0 with 7676 MB memory: -> device: 0, name: AMD Radeon RX 6600 XT, pci bus id: 0000:08:00.0\n"
"at w.execute (/home/ta180m/.vscode-oss/extensions/ms-toolsai.jupyter-2021.10.100/out/client/extension.js:52:301589)",
"at w.start (/home/ta180m/.vscode-oss/extensions/ms-toolsai.jupyter-2021.10.100/out/client/extension.js:52:297159)",
"at processTicksAndRejections (internal/process/task_queues.js:93:5)",
"at async t.CellExecutionQueue.executeQueuedCells (/home/ta180m/.vscode-oss/extensions/ms-toolsai.jupyter-2021.10.100/out/client/extension.js:52:312368)",
"at async t.CellExecutionQueue.start (/home/ta180m/.vscode-oss/extensions/ms-toolsai.jupyter-2021.10.100/out/client/extension.js:52:311908)"
] ]
},
{
"data": {
"text/plain": [
"[name: \"/device:CPU:0\"\n",
" device_type: \"CPU\"\n",
" memory_limit: 268435456\n",
" locality {\n",
" }\n",
" incarnation: 4131910275298190244,\n",
" name: \"/device:GPU:0\"\n",
" device_type: \"GPU\"\n",
" memory_limit: 8048869376\n",
" locality {\n",
" bus_id: 2\n",
" numa_node: 1\n",
" links {\n",
" }\n",
" }\n",
" incarnation: 8120473677084580141\n",
" physical_device_desc: \"device: 0, name: AMD Radeon RX 6600 XT, pci bus id: 0000:08:00.0\"]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [ "source": [
@ -227,9 +237,17 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2021-12-13 18:36:29.743574: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1510] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 7676 MB memory: -> device: 0, name: AMD Radeon RX 6600 XT, pci bus id: 0000:08:00.0\n"
]
}
],
"source": [ "source": [
"model = tf.keras.models.Sequential([\n", "model = tf.keras.models.Sequential([\n",
" tf.keras.layers.Flatten(input_shape=(28, 28)),\n", " tf.keras.layers.Flatten(input_shape=(28, 28)),\n",
@ -245,18 +263,18 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[ 0.02972372, -0.0031659 , 0.10770161, 0.06811108, 0.15003528,\n", "array([[ 0.05019438, -0.11693908, 0.0457226 , -0.10117609, 0.07739688,\n",
" -0.13823937, 0.15633231, -0.06459978, 0.12190703, -0.01581882]],\n", " -0.15473695, -0.09796654, -0.06173493, -0.08286384, 0.1133035 ]],\n",
" dtype=float32)" " dtype=float32)"
] ]
}, },
"execution_count": 20, "execution_count": 8,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -275,7 +293,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -302,7 +320,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 22, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -322,7 +340,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 23, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -330,34 +348,50 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Epoch 1/10\n", "Epoch 1/10\n",
"1875/1875 [==============================] - 4s 2ms/step - loss: 0.2636 - accuracy: 0.9182\n", " 107/1875 [>.............................] - ETA: 2s - loss: 0.0625 - accuracy: 0.9807"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2021-12-13 18:37:40.224182: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n",
"2021-12-13 18:37:40.226497: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n",
"2021-12-13 18:37:40.228452: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1875/1875 [==============================] - 3s 2ms/step - loss: 0.0572 - accuracy: 0.9823\n",
"Epoch 2/10\n", "Epoch 2/10\n",
"1875/1875 [==============================] - 4s 2ms/step - loss: 0.1454 - accuracy: 0.9566\n", "1875/1875 [==============================] - 3s 1ms/step - loss: 0.0556 - accuracy: 0.9830\n",
"Epoch 3/10\n", "Epoch 3/10\n",
"1875/1875 [==============================] - 4s 2ms/step - loss: 0.1203 - accuracy: 0.9644\n", "1875/1875 [==============================] - 3s 2ms/step - loss: 0.0520 - accuracy: 0.9845\n",
"Epoch 4/10\n", "Epoch 4/10\n",
"1875/1875 [==============================] - 4s 2ms/step - loss: 0.0991 - accuracy: 0.9701\n", "1875/1875 [==============================] - 3s 1ms/step - loss: 0.0505 - accuracy: 0.9851\n",
"Epoch 5/10\n", "Epoch 5/10\n",
"1875/1875 [==============================] - 4s 2ms/step - loss: 0.0902 - accuracy: 0.9728\n", "1875/1875 [==============================] - 5s 3ms/step - loss: 0.0506 - accuracy: 0.9847\n",
"Epoch 6/10\n", "Epoch 6/10\n",
"1875/1875 [==============================] - 4s 2ms/step - loss: 0.0787 - accuracy: 0.9757\n", "1875/1875 [==============================] - 3s 1ms/step - loss: 0.0479 - accuracy: 0.9858\n",
"Epoch 7/10\n", "Epoch 7/10\n",
"1875/1875 [==============================] - 4s 2ms/step - loss: 0.0734 - accuracy: 0.9781\n", "1875/1875 [==============================] - 3s 2ms/step - loss: 0.0474 - accuracy: 0.9865\n",
"Epoch 8/10\n", "Epoch 8/10\n",
"1875/1875 [==============================] - 4s 2ms/step - loss: 0.0700 - accuracy: 0.9785\n", "1875/1875 [==============================] - 3s 1ms/step - loss: 0.0474 - accuracy: 0.9866\n",
"Epoch 9/10\n", "Epoch 9/10\n",
"1875/1875 [==============================] - 4s 2ms/step - loss: 0.0630 - accuracy: 0.9805\n", "1875/1875 [==============================] - 3s 1ms/step - loss: 0.0463 - accuracy: 0.9867\n",
"Epoch 10/10\n", "Epoch 10/10\n",
"1875/1875 [==============================] - 4s 2ms/step - loss: 0.0641 - accuracy: 0.9815\n" "1875/1875 [==============================] - 3s 1ms/step - loss: 0.0434 - accuracy: 0.9876\n"
] ]
}, },
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"<keras.callbacks.History at 0x7fbfe03bcbe0>" "<keras.callbacks.History at 0x7fd8c0525490>"
] ]
}, },
"execution_count": 23, "execution_count": 12,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -375,23 +409,33 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2021-12-13 18:38:18.485616: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n",
"2021-12-13 18:38:18.489485: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n",
"2021-12-13 18:38:18.492379: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n",
"2021-12-13 18:38:18.559492: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n"
]
},
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"313/313 - 0s - loss: 0.0758 - accuracy: 0.9768 - 158ms/epoch - 505us/step\n" "313/313 - 0s - loss: 0.0782 - accuracy: 0.9808\n"
] ]
}, },
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"[0.07581057399511337, 0.9768000245094299]" "[0.07822339236736298, 0.9807999730110168]"
] ]
}, },
"execution_count": 12, "execution_count": 13,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }