ebay-ml-lister/testing.ipynb

125 lines
2.7 KiB
Plaintext
Raw Normal View History

2021-12-31 22:08:48 +00:00
{
"cells": [
{
"cell_type": "code",
2022-08-03 03:14:38 +00:00
"execution_count": 5,
2021-12-31 22:08:48 +00:00
"id": "7eea0d4d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-08-03 03:14:38 +00:00
"Num GPUs Available: 2\n"
2021-12-31 22:08:48 +00:00
]
}
],
"source": [
"import tensorflow as tf\n",
"print(\"Num GPUs Available: \", len(tf.config.list_physical_devices('GPU')))\n"
]
},
{
"cell_type": "code",
2022-08-03 03:14:38 +00:00
"execution_count": 6,
2021-12-31 22:08:48 +00:00
"id": "33d18ebd",
"metadata": {},
"outputs": [
{
2022-08-03 03:14:38 +00:00
"name": "stdout",
2021-12-31 22:08:48 +00:00
"output_type": "stream",
"text": [
2022-08-03 03:14:38 +00:00
"2 Physical GPU, 3 Logical GPUs\n"
2021-12-31 22:08:48 +00:00
]
2022-08-03 03:14:38 +00:00
}
],
"source": [
"gpus = tf.config.list_physical_devices('GPU')\n",
"if gpus:\n",
" # Create 2 virtual GPUs with 1GB memory each\n",
" try:\n",
" tf.config.set_logical_device_configuration(\n",
" gpus[0],\n",
" [tf.config.LogicalDeviceConfiguration(memory_limit=1024),\n",
" tf.config.LogicalDeviceConfiguration(memory_limit=1024)])\n",
" logical_gpus = tf.config.list_logical_devices('GPU')\n",
" print(len(gpus), \"Physical GPU,\", len(logical_gpus), \"Logical GPUs\")\n",
" except RuntimeError as e:\n",
" # Virtual devices must be set before GPUs have been initialized\n",
" print(e)\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "2b9ca96e",
"metadata": {},
"outputs": [
2021-12-31 22:08:48 +00:00
{
"name": "stdout",
"output_type": "stream",
"text": [
"tf.Tensor(\n",
"[[22. 28.]\n",
" [49. 64.]], shape=(2, 2), dtype=float32)\n"
]
}
],
"source": [
"tf.debugging.set_log_device_placement(True)\n",
"\n",
"a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])\n",
"b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])\n",
"\n",
"# Run on the GPU\n",
"c = tf.matmul(a, b)\n",
"print(c)\n",
"\n"
]
},
2022-08-03 03:14:38 +00:00
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"from keras.models import load_model\n",
"\n",
"# returns a compiled model\n",
"# identical to the previous one\n",
"model = load_model('Model_1.h5')"
]
},
2021-12-31 22:08:48 +00:00
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
2022-08-03 03:14:38 +00:00
"source": [
"model.predict_generator()"
]
2021-12-31 22:08:48 +00:00
}
],
"metadata": {
"kernelspec": {
2022-08-03 03:14:38 +00:00
"display_name": "Python 3",
2021-12-31 22:08:48 +00:00
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2022-08-03 03:14:38 +00:00
"version": "3.8.10"
2021-12-31 22:08:48 +00:00
}
},
"nbformat": 4,
"nbformat_minor": 5
}