{"id":15977039,"url":"https://github.com/tobybreckon/python-cnn-tools-test","last_synced_at":"2025-03-17T22:31:10.329Z","repository":{"id":152042023,"uuid":"152247313","full_name":"tobybreckon/python-cnn-tools-test","owner":"tobybreckon","description":"a set of simple tools to check if we have TensorFlow, Keras and PyTorch setup correctly to use GPU","archived":false,"fork":false,"pushed_at":"2024-09-16T12:18:54.000Z","size":47,"stargazers_count":3,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T05:47:48.038Z","etag":null,"topics":["gpu","keras","opencv","pytorch","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tobybreckon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-09T12:29:26.000Z","updated_at":"2024-09-16T12:18:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"0769a6ca-179d-44e5-8afa-64c465208dc8","html_url":"https://github.com/tobybreckon/python-cnn-tools-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobybreckon%2Fpython-cnn-tools-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobybreckon%2Fpython-cnn-tools-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobybreckon%2Fpython-cnn-tools-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobybreckon%2Fpython-cnn-tools-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobybreckon","download_url":"https://codeload.github.com/tobybreckon/python-cnn-tools-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243891356,"owners_count":20364576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpu","keras","opencv","pytorch","tensorflow"],"created_at":"2024-10-07T22:42:04.826Z","updated_at":"2025-03-17T22:31:09.937Z","avatar_url":"https://github.com/tobybreckon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Verification Testing for Deep Learning CNN Tools\n\nAs Tensorflow, Keras and Pytorch are complex pieces of software, to ensure the GPU installation of each is working correctly we perform the following simple tests.\n\nAll tested with Tensorflow, Keras, Pytorch and Python 3.x (with OpenCV as needed) **on Linux**.\n\n * For **TensorFlow 1.x** only - use tests 1, 4 and 5 only.\n * For **TensorFlow 2.x** only - use tests 1 and 6 only.\n * For **Keras** (which uses TensorFlow as a backend) - use test 2 only.\n * For **PyTorch** only - use test 3 only (and 3a for testing with OpenCV also).\n * _See very simple test 1a for additionally testing sci-kit-learn is available in the same python environment_\n\nN.B. Durham Students - ***if testing/using on the Durham University LDS (linux) system*** you need to first run ```tensorflowX.X.X.init```, ```pytorchX.X.X.init``` and ```opencvX.X.X.init``` in the (Linux, not the Python) command shell where X.X.X is the version number, or alternatively without it which should hopefully default to the latest version installed (e.g. ```tensorflow.init```, ```pytorch.init```, ```opencv.init```), to add the relevant paths for these tools to the ```PYTHONPATH``` environment variable (and be sitting at a machine with a GPU in it!).\n\n_Assumes that the git, wget, md5sum and curl tools are available on the command line or that similar tools are available to access git / download files._\n\n**Tests 3a, 4 and 5 assume you have OpenCV aleady installed** (with the extra modules also for Test 5) - OpenCV has its own testing page and test suite here - https://github.com/tobybreckon/python-examples-ip/blob/master/TESTING.md\n\nAn additional test script for MxNet is also available (```mxnet-test.py```) but this is not currently included within the the set of software supported by the set of explicit tests below\n(which is primarily used to test our on campus teaching lab provision of TensorFlow, Keras and Pytorch at [Durham University](https:/www.durham.ac.uk/)).\n\n---\n\n## Test #1 - check TensorFlow (1.x or 2.x):\n\n```\ngit clone https://github.com/tobybreckon/python-cnn-tools-test.git\ncd python-cnn-tools-test\npython3 ./tf-test.py\n```\n### Result #1:\n\nText output to console such that:\n\n```\nWe are using tensorflow: T.T.T\n\nWe believe we have the following devices available:\n\n[name: \"/device:CPU:0\"\ndevice_type: \"CPU\"\nmemory_limit: MMMM\n???\n]\n[name: \"/device:GPU:0\"\ndevice_type: \"GPU\"\nmemory_limit: MMMM\n???\n]\n\n\nTesting tensorflow with CPU ....\n???\n[[22. 28.]\n [49. 64.]]\nCPU computation *** success ***.\n\nTesting tensorflow with GPU ....\n???\n[[22. 28.]\n [49. 64.]]\nGPU computation *** success ***.\n\nWe are using numpy: ???\nWe are using matplotlib: ???\n.. and this is in Python: PPP\n\n```\n...  where T.T.T \u003e= 2.x.x; MMM \u003e 0; PPP \u003e 3.x; ??? = (doesn't matter)\n\n---\n\n## Test #1a - check Scikit-Learn toolkit\n\n[this is also very useful to have for most machine learning]\n\n```\n.. (as per test 1 for steps 1 + 2 - no need to repeat if already completed)\npython3 ./sklearn-test.py\n```\n\n### Result #1a:\n\nText output to console such that:\n\n```\nscikit-learn is available - version: S.S.S.\n\nWe are using numpy: ???\nWe are using matplotlib: ???\n.. and this is in Python: PPP\n\n```\n... where S.S.S \u003e= 0.20.x (or higher); PPP \u003e 3.x; ??? = (doesn't matter)\n\n---\n\n## Test #2 - check Keras\n\n\n```\n.. (as per test 1 for steps 1 + 2 - no need to repeat if already completed)\npython3 ./keras-test.py\n```\n\n### Result #2:\n\nText output to console such that:\n\n```\n???\nWe are using keras: K.K.K\n\nWe are using the following keras backend:\ntensorflow\n\n\nWe are using numpy: ???\nWe are using matplotlib: ???\n.. and this is in Python: PPP\n\n```\n... where K.K.K \u003e= 2.2.x (or higher); PPP \u003e 3.x; ??? = (doesn't matter, ignore warnings)\n\n---\n\n## Test #3 - check Pytorch\n\n```\n.. (as per test 1 for steps 1 + 2 - no need to repeat if already completed)\npython3 ./pytorch-test.py\n```\n\n### Result #3:\n\nText output to console such that:\n\n```\nWe are using pytorch: PT.PT.PT\nWe believe we have the following # of GPU:\n1\nThe first GPU available is:\n\u003cDEVICE STRING NAME\u003e\n\nTesting pytorch with CPU ....\nCPU computation *** success ***.\n\nTesting pytorch with GPU ....\nGPU computation *** success ***.\n\nWe are using numpy: ???\nWe are using matplotlib: ???\n.. and this is in Python: PPP\n\n```\n... where PT.PT.PT \u003e= 2.x.x (or higher); \"DEVICE STRING NAME\" looks sensible given the GPU in the machine; PPP \u003e 3.x; ??? = (doesn't matter)\n\n---\n\n## Test #3a - check Pytorch with OpenCV\n\n```\n.. (as per test 1 for steps 1 + 2 - no need to repeat if already completed)\npython3 ./pytorch-opencv-test.py\n```\n\n### Result #3a:\n\nText output to console such that:\n\n```\nWe are using pytorch: PT.PT.PT\nWe believe we have the following # of GPU:\n1\nThe first GPU available is:\n\u003cDEVICE STRING NAME\u003e\n\nWe are using OpenCV: CCC\n.. do we have the OpenCV Contrib Modules: True\n.. do we have the OpenCV Non-free algorithms: True\nWe are using numpy: \u003c???\u003e\nWe are using matplotlib: \u003c???\u003e\n.. and this is in Python: PPP ??? (64 bit)\n\nCheck Video I/O (OS identifier: MMM)\n... available camera backends:  LLL\n... available stream backends:  LLL\n... available video writer backends: LLL\n\nAvailable Cuda Information:\n... ['NVIDIA CUDA: YES (ver NNN, RRR)', 'NVIDIA GPU arch: ???', 'NVIDIA PTX archs: ZZZ']\n\nOpenCL available (within OpenCV) ? : True\n\n```\n... where PT.PT.PT \u003e= 2.x.x (or higher); \"DEVICE STRING NAME\" looks sensible given the GPU in the machine; CCC \u003e= 4.10.x (or higher), PPP \u003e 3.x, MMM is sensible for the OS in use, each of the LLL list are sensible (may not all be identical) and ideally include FFMPEG + GSTREAMER in addition to V4L/V4L (for MMM = linux..), QT (for MMM = darwin) or DSHOW / MSMF (for MMM = win..), NNN \u003e 10.x, ZZZ includes ``cuDNN: Yes`` and ??? = (doesn't matter). In addition, for maximum performance RRR ideally includes ``CUFFT CUBLAS FAST_MATH``.\n\nIdeally, the OpenCV install would also pass the full set of tests in [this document](https://github.com/tobybreckon/python-examples-ip/blob/master/TESTING.md).\n\n[ to build with Non-free algorithms set OPENCV_ENABLE_NONFREE=TRUE in CMake ]\n\n---\n\n## Test #4 - TensorFlow 1.x and OpenCV full system check - low performance\n\n* this tests we can use basic OpenCV (hopefully 4.x) with TensorFlow 1.x in the same python script\n\n```\ngit clone https://github.com/tobybreckon/fire-detection-cnn.git\ncd fire-detection-cnn\nsh ./download-models.sh\npython3 firenet.py models/test.mp4\n\n```\n\n### Result #4:\n\nText output to console such that:\n\n```\n???\nConstructed FireNet ...\n???\nLoaded CNN network weights ...\nLoaded video ..\n```\n\n... ??? = (detail doesn't matter but should clearly indicate GPU usage by type/name/bus or similar)\n\nThen:\n\n- model download (step 3) will depend on network speed\n- **video displayed in real-time, is not slow or jerky,** and appropriate  Red Fire/Green Clear labels displayed depending on contents of image frame\n- may need to resize window to display full image correctly. Or press \"f\" for fullscreen mode.\n- Press \"x\" to exit\n\n---\n\n## Test #5 - TensorFlow 1.x and OpenCV full system check - high performance\n\n* this tests we can use advanced extra module functionality within OpenCV (hopefully 4.x) with TensorFlow 1.x in the same python script\n\n```\n(as per steps 1-3 of Test 4 - no need to repeat if already completed)\npython3 superpixel-inceptionV1OnFire.py models/test.mp4\n\n```\n\n### Result #5:\n\nText output to console such that:\n\n```\n???\nConstructed SP-InceptionV1-OnFire ...\n???\nLoaded CNN network weights ...\nLoaded video ..\n```\n\n... ??? = (detail doesn't matter but should clearly indicate GPU usage by type/name/bus or similar)\n\nThen:\n\n- video displayed in real-time, is not slow or jerky **with update of several frames per second observed**, and appropriate Red/Green labels displayed depending on contents of  (where Green is fire regions)\n- Press \"x\" to exit\n\n---\n\n## Test #6 - TensorFlow 2.x and OpenCV full system check\n\n* this tests we can use a OpenCV (hopefully 4.x) with TensorFlow 2.x in the same python script\n\n```\npython3 ./tf-opencv-test.py\n\n\n```\n\n### Result #6:\n\nText output to console such that:\n\n```\nWe are using tensorflow: T.T.T\n\nWe believe we have the following devices available:\n\n[name: \"/device:CPU:0\"\ndevice_type: \"CPU\"\nmemory_limit: MMMM\n???\n]\n[name: \"/device:GPU:0\"\ndevice_type: \"GPU\"\nmemory_limit: MMMM\n???\n]\n\nTesting tensorflow with CPU ....\n???\n[[22. 28.]\n [49. 64.]]\nCPU computation *** success ***.\n\nTesting tensorflow with GPU ....\n???\n[[22. 28.]\n [49. 64.]]\nGPU computation *** success ***.\n\nWe are using numpy: ???\nWe are using matplotlib: ???\n.. and this is in Python: PPP\n\nWe are using OpenCV: CCC\n.. do we have the OpenCV Contrib Modules: True\n.. do we have the OpenCV Non-free algorithms: True\nWe are using numpy: \u003c???\u003e\nWe are using matplotlib: \u003c???\u003e\n.. and this is in Python: PPP ??? (64 bit)\n\nCheck Video I/O (OS identifier: MMM)\n... available camera backends:  LLL\n... available stream backends:  LLL\n... available video writer backends: LLL\n\nAvailable Cuda Information:\n... ['NVIDIA CUDA: YES (ver NNN, RRR)', 'NVIDIA GPU arch: ???', 'NVIDIA PTX archs: ZZZ']\n\nOpenCL available (within OpenCV) ? : True\n\n```\n...  where T.T.T \u003e= 2.x.x; MMM \u003e 0; PPP \u003e 3.x; ??? = (doesn't matter); CCC \u003e= 4.10.x (or higher), PPP \u003e 3.x, MMM is sensible for the OS in use, each of the LLL list are sensible (may not all be identical) and ideally include FFMPEG + GSTREAMER in addition to V4L/V4L (for MMM = linux..), QT (for MMM = darwin) or DSHOW / MSMF (for MMM = win..), NNN \u003e 10.x, ZZZ includes ``cuDNN: Yes`` and ??? = (doesn't matter). In addition, for maximum performance RRR ideally includes ``CUFFT CUBLAS FAST_MATH``.\n\nIdeally, the OpenCV install would also pass the full set of tests in [this document](https://github.com/tobybreckon/python-examples-ip/blob/master/TESTING.md).\n\n[ to build with Non-free algorithms set OPENCV_ENABLE_NONFREE=TRUE in CMake ]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobybreckon%2Fpython-cnn-tools-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobybreckon%2Fpython-cnn-tools-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobybreckon%2Fpython-cnn-tools-test/lists"}