Skip to content

Instantly share code, notes, and snippets.

@hasibzunair
Created December 19, 2019 19:08
Show Gist options
  • Save hasibzunair/dfec5010d84baabcaa70e4271b69856b to your computer and use it in GitHub Desktop.
Save hasibzunair/dfec5010d84baabcaa70e4271b69856b to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"nvcc: NVIDIA (R) Cuda compiler driver\n",
"Copyright (c) 2005-2018 NVIDIA Corporation\n",
"Built on Sat_Aug_25_21:08:04_Central_Daylight_Time_2018\n",
"Cuda compilation tools, release 10.0, V10.0.130\n"
]
}
],
"source": [
"!nvcc --version"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#import os\n",
"#os.environ[\"CUDA_DEVICE_ORDER\"] = \"PCI_BUS_ID\" \n",
"# The GPU id to use, usually either \"0\" or \"1\";\n",
"#os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"1\" # use id from $ nvidia-smi"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Keras Version 2.2.5\n",
"Tensorflow Version 1.15.0\n"
]
}
],
"source": [
"# Print version\n",
"print(\"Keras Version\", keras.__version__)\n",
"print(\"Tensorflow Version\", tf.__version__)\n",
"\n",
"# use this version\n",
"#Keras Version 2.3.1\n",
"#Tensorflow Version 2.0.0\n",
"\n",
"# conda install -c conda-forge keras\n",
"# conda install -c anaconda tensorflow-gpu"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['/device:GPU:0']\n"
]
}
],
"source": [
"# GPU test\n",
"from tensorflow.python.client import device_lib\n",
"def get_available_gpus():\n",
" local_device_protos = device_lib.list_local_devices()\n",
" return [x.name for x in local_device_protos if x.device_type == 'GPU']\n",
"\n",
"print(get_available_gpus())"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[name: \"/device:CPU:0\"\n",
" device_type: \"CPU\"\n",
" memory_limit: 268435456\n",
" locality {\n",
" }\n",
" incarnation: 7058356687516318937, name: \"/device:GPU:0\"\n",
" device_type: \"GPU\"\n",
" memory_limit: 9108882063\n",
" locality {\n",
" bus_id: 1\n",
" links {\n",
" }\n",
" }\n",
" incarnation: 7427185872298565116\n",
" physical_device_desc: \"device: 0, name: GeForce RTX 2080 Ti, pci bus id: 0000:01:00.0, compute capability: 7.5\"]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get compute specs\n",
"from tensorflow.python.client import device_lib\n",
"device_lib.list_local_devices()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tf.test.is_built_with_cuda()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tf.test.is_gpu_available()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment