|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "import os\n", |
| 10 | + "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'\n", |
| 11 | + "\n", |
| 12 | + "import tensorflow as tf\n", |
| 13 | + "if tf.test.gpu_device_name()=='':\n", |
| 14 | + " print('You do not have GPU access.') \n", |
| 15 | + " print('Did you change your runtime ?') \n", |
| 16 | + " print('If the runtime setting is correct then Google did not allocate a GPU for your session')\n", |
| 17 | + " print('Expect slow performance. To access GPU try reconnecting later')\n", |
| 18 | + "\n", |
| 19 | + "else:\n", |
| 20 | + " print('You have GPU access')\n", |
| 21 | + " !nvidia-smi\n", |
| 22 | + "\n", |
| 23 | + "# from tensorflow.python.client import device_lib \n", |
| 24 | + "# device_lib.list_local_devices()\n", |
| 25 | + "\n", |
| 26 | + "# print the tensorflow version\n", |
| 27 | + "print('Tensorflow version is ' + str(tf.__version__))" |
| 28 | + ] |
| 29 | + } |
| 30 | + ], |
| 31 | + "metadata": { |
| 32 | + "kernelspec": { |
| 33 | + "display_name": ".venv", |
| 34 | + "language": "python", |
| 35 | + "name": "python3" |
| 36 | + }, |
| 37 | + "language_info": { |
| 38 | + "codemirror_mode": { |
| 39 | + "name": "ipython", |
| 40 | + "version": 3 |
| 41 | + }, |
| 42 | + "file_extension": ".py", |
| 43 | + "mimetype": "text/x-python", |
| 44 | + "name": "python", |
| 45 | + "nbconvert_exporter": "python", |
| 46 | + "pygments_lexer": "ipython3", |
| 47 | + "version": "3.10.6" |
| 48 | + }, |
| 49 | + "orig_nbformat": 4, |
| 50 | + "vscode": { |
| 51 | + "interpreter": { |
| 52 | + "hash": "185732d1a0c8de10c9bb03975f56b22bfc308b23770b008cd7b656c75bc57aea" |
| 53 | + } |
| 54 | + } |
| 55 | + }, |
| 56 | + "nbformat": 4, |
| 57 | + "nbformat_minor": 2 |
| 58 | +} |
0 commit comments