From 42eb7a9735b6f11a2d1abea8f5fa0d4025a7e5f7 Mon Sep 17 00:00:00 2001 From: Simon Klix Date: Fri, 6 Sep 2024 16:58:08 +0200 Subject: [PATCH] small changes to python scripts --- .../scripts/installation/uninstall.sh | 22 +++++++++++++++++++ .../scripts/testing/minimal_cuda_test.py | 9 ++++++++ .../scripts/testing/minimal_test.py | 13 ++++++++++- .../testing/minimal_test_benchmarks.py | 16 +++++++++++--- 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100755 plugins/machine_learning/scripts/installation/uninstall.sh create mode 100644 plugins/machine_learning/scripts/testing/minimal_cuda_test.py diff --git a/plugins/machine_learning/scripts/installation/uninstall.sh b/plugins/machine_learning/scripts/installation/uninstall.sh new file mode 100755 index 00000000000..e6ba8dbb71d --- /dev/null +++ b/plugins/machine_learning/scripts/installation/uninstall.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Stop on the first sign of trouble +set -e + +echo "Removing all NVIDIA drivers and CUDA packages..." + +# Remove the NVIDIA driver +sudo apt-get purge -y '*nvidia*' + +# Remove CUDA Toolkit and associated packages +sudo apt-get purge -y '*cuda*' +sudo apt-get purge -y '*cublas*' '*cufft*' '*curand*' '*cusolver*' '*cusparse*' '*npp*' '*nvjpeg*' + +# Autoremove remaining dependencies +sudo apt-get autoremove -y + +# Remove any remaining NVIDIA and CUDA directories +sudo rm -rf /usr/local/cuda* + +echo "Uninstallation complete. Please reboot the system." + diff --git a/plugins/machine_learning/scripts/testing/minimal_cuda_test.py b/plugins/machine_learning/scripts/testing/minimal_cuda_test.py new file mode 100644 index 00000000000..884c4301eef --- /dev/null +++ b/plugins/machine_learning/scripts/testing/minimal_cuda_test.py @@ -0,0 +1,9 @@ +import torch + +print(torch.__version__) +print(torch.version.cuda) +print(torch.cuda.is_available()) + + +x = torch.rand(5, 3).cuda() +print(x) diff --git a/plugins/machine_learning/scripts/testing/minimal_test.py b/plugins/machine_learning/scripts/testing/minimal_test.py index 87d730756b6..6abd72d9d44 100644 --- a/plugins/machine_learning/scripts/testing/minimal_test.py +++ b/plugins/machine_learning/scripts/testing/minimal_test.py @@ -3,7 +3,18 @@ import pathlib #some necessary configuration: -base_path = "/home/simon/projects/hal/" +user_name = os.getlogin() + +# some necessary configuration: +if user_name == "simon": + base_path = "/home/simon/projects/hal/" + benchmarks_base_path = pathlib.Path("/home/simon/projects/benchmarks") +if user_name == "klix": + base_path = "/home/klix/projects/hal/" + benchmarks_base_path = pathlib.Path("/home/klix/projects/benchmarks") +else: + print("add base paths foe user {}before executing...".format(user_name)) + exit() sys.path.append(base_path + "build/lib/") #this is where your hal python lib is located os.environ["HAL_BASE_PATH"] = base_path + "build" # hal base path diff --git a/plugins/machine_learning/scripts/testing/minimal_test_benchmarks.py b/plugins/machine_learning/scripts/testing/minimal_test_benchmarks.py index 10e000f5fbf..0c1bfe93cbb 100644 --- a/plugins/machine_learning/scripts/testing/minimal_test_benchmarks.py +++ b/plugins/machine_learning/scripts/testing/minimal_test_benchmarks.py @@ -2,8 +2,18 @@ import sys, os import pathlib -#some necessary configuration: -base_path = "/home/simon/projects/hal/" +user_name = os.getlogin() + +# some necessary configuration: +if user_name == "simon": + base_path = "/home/simon/projects/hal/" + benchmarks_base_path = pathlib.Path("/home/simon/projects/benchmarks") +if user_name == "klix": + base_path = "/home/klix/projects/hal" + benchmarks_base_path = pathlib.Path("/home/klix/projects/benchmarks") +else: + print("add base paths for user {}before executing...".format(user_name)) + exit() sys.path.append(base_path + "build/lib/") #this is where your hal python lib is located os.environ["HAL_BASE_PATH"] = base_path + "build" # hal base path @@ -15,7 +25,7 @@ #initialize HAL hal_py.plugin_manager.load_all_plugins() -benchmarks_base_path = pathlib.Path("/home/simon/projects/benchmarks") + netlist_base_paths = benchmarks_base_path / "netlists_preprocessed/yosys/NangateOpenCellLibrary_functional" netlist_paths = list()