From a40befe4ee243c168650a9f3e077030a5bd4a86d Mon Sep 17 00:00:00 2001 From: viclafargue Date: Fri, 3 Feb 2023 14:47:16 +0100 Subject: [PATCH] renaming device type setter --- .../execution_device_interoperability.ipynb | 34 ++++++++++++------- python/cuml/common/device_selection.py | 2 +- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/docs/source/execution_device_interoperability.ipynb b/docs/source/execution_device_interoperability.ipynb index 87fe2c65b7..64e519ddb3 100644 --- a/docs/source/execution_device_interoperability.ipynb +++ b/docs/source/execution_device_interoperability.ipynb @@ -11,12 +11,12 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "source": [ "import pickle\n", "import cuml\n", "from cuml.common.device_selection import using_device_type\n", - "from cuml.common.device_selection import set_global_device_type, get_current_device_type\n", + "from cuml.common.device_selection import set_global_device_type, get_global_device_type\n", "from cuml.neighbors import NearestNeighbors\n", "from cuml.manifold import UMAP\n", "from cuml.linear_model import LinearRegression\n", @@ -41,7 +41,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 2, "source": [ "nn = NearestNeighbors()\n", "with using_device_type('cpu'):\n", @@ -60,7 +60,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 3, "source": [ "umap_model = UMAP(angular_rp_forest=True) # `angular_rp_forest` hyperparameter only available in UMAP library\n", "with using_device_type('cpu'):\n", @@ -73,7 +73,15 @@ "output_type": "stream", "name": "stdout", "text": [ - "[I] [16:40:12.572459] Unused keyword parameter: angular_rp_forest during cuML estimator initialization\n" + "[I] [14:46:20.500110] Unused keyword parameter: angular_rp_forest during cuML estimator initialization\n" + ] + }, + { + "output_type": "stream", + "name": "stderr", + "text": [ + "/home/vic/mambaforge/envs/all_cuda-115_arch-x86_64/lib/python3.9/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" ] } ], @@ -90,7 +98,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 4, "source": [ "lin_reg = LinearRegression()\n", "with using_device_type('gpu'):\n", @@ -111,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 5, "source": [ "recovered_lin_reg = pickle.load(open(\"lin_reg.pkl\", \"rb\"))\n", "with using_device_type('cpu'):\n", @@ -129,9 +137,9 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 6, "source": [ - "initial_device_type = get_current_device_type()\n", + "initial_device_type = get_global_device_type()\n", "print('default execution device:', initial_device_type)" ], "outputs": [ @@ -154,11 +162,11 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 7, "source": [ "for param in ['cpu', 'host', 'gpu', 'device']:\n", " with using_device_type(param):\n", - " print('using_device_type({}):'.format(param), get_current_device_type())" + " print('using_device_type({}):'.format(param), get_global_device_type())" ], "outputs": [ { @@ -183,10 +191,10 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 8, "source": [ "set_global_device_type('gpu')\n", - "print('new device type:', get_current_device_type())" + "print('new device type:', get_global_device_type())" ], "outputs": [ { diff --git a/python/cuml/common/device_selection.py b/python/cuml/common/device_selection.py index 248197a062..8005f4983a 100644 --- a/python/cuml/common/device_selection.py +++ b/python/cuml/common/device_selection.py @@ -23,7 +23,7 @@ def set_global_device_type(device_type): GlobalSettings().device_type = DeviceType.from_str(device_type) -def get_current_device_type(): +def get_global_device_type(): return GlobalSettings().device_type