-
-
Save martinhoang11/998c03b038a4f41b450cb007ba5e20dd to your computer and use it in GitHub Desktop.
Colab_25GBRAM_GPU.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Colab_25GBRAM_GPU.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"toc_visible": true, | |
"machine_shape": "hm", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"accelerator": "GPU" | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/VinhDevNguyen/ac165c64de10ee93d47b8b2d99e866ca/colab_25gbram_gpu.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "EdHVQrqyDB50" | |
}, | |
"source": [ | |
"# Memory Information" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "E58HaeA6CsM9", | |
"outputId": "a4a1713d-4e1e-4239-b6bf-9400ce116d84", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"import psutil\n", | |
"def get_size(bytes, suffix=\"B\"):\n", | |
" factor = 1024\n", | |
" for unit in [\"\", \"K\", \"M\", \"G\", \"T\", \"P\"]:\n", | |
" if bytes < factor:\n", | |
" return f\"{bytes:.2f}{unit}{suffix}\"\n", | |
" bytes /= factor\n", | |
"print(\"=\"*40, \"Memory Information\", \"=\"*40)\n", | |
"svmem = psutil.virtual_memory()\n", | |
"print(f\"Total: {get_size(svmem.total)}\") ; print(f\"Available: {get_size(svmem.available)}\")\n", | |
"print(f\"Used: {get_size(svmem.used)}\") ; print(f\"Percentage: {svmem.percent}%\")" | |
], | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"======================================== Memory Information ========================================\n", | |
"Total: 25.51GB\n", | |
"Available: 24.60GB\n", | |
"Used: 589.02MB\n", | |
"Percentage: 3.6%\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "FgVfBlvZDEja" | |
}, | |
"source": [ | |
"# GPU Information" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "rxlkxvkrCyin", | |
"outputId": "5923c724-5489-4956-8ce0-0a9ddb3506ee", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"from tensorflow.python.client import device_lib\n", | |
"device_lib.list_local_devices()" | |
], | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"[name: \"/device:CPU:0\"\n", | |
" device_type: \"CPU\"\n", | |
" memory_limit: 268435456\n", | |
" locality {\n", | |
" }\n", | |
" incarnation: 10611489201285832476, name: \"/device:XLA_CPU:0\"\n", | |
" device_type: \"XLA_CPU\"\n", | |
" memory_limit: 17179869184\n", | |
" locality {\n", | |
" }\n", | |
" incarnation: 13794914038225246883\n", | |
" physical_device_desc: \"device: XLA_CPU device\", name: \"/device:XLA_GPU:0\"\n", | |
" device_type: \"XLA_GPU\"\n", | |
" memory_limit: 17179869184\n", | |
" locality {\n", | |
" }\n", | |
" incarnation: 12183848674222790767\n", | |
" physical_device_desc: \"device: XLA_GPU device\", name: \"/device:GPU:0\"\n", | |
" device_type: \"GPU\"\n", | |
" memory_limit: 15695549568\n", | |
" locality {\n", | |
" bus_id: 1\n", | |
" links {\n", | |
" }\n", | |
" }\n", | |
" incarnation: 2862162821271877293\n", | |
" physical_device_desc: \"device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0\"]" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 2 | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment