Skip to content

Commit dfb03a0

Browse files
authored
[oneDNN] Add GPU instructions to benchDNN tutorial (#1551)
* [oneDNN] Rename to tutorial_benchdnn * [oneDNN] benchdnn sample add GPU support
1 parent 09e8929 commit dfb03a0

File tree

1 file changed

+119
-4
lines changed

1 file changed

+119
-4
lines changed

Libraries/oneDNN/tutorials/benchdnn_tutorial.ipynb renamed to Libraries/oneDNN/tutorials/tutorial_benchdnn.ipynb

+119-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"name": "stdout",
8383
"output_type": "stream",
8484
"text": [
85-
"Error! wrong oneAPI installation path\n"
85+
"Success! found oneAPI installation\n"
8686
]
8787
}
8888
],
@@ -94,6 +94,22 @@
9494
" print(\"Success! found oneAPI installation\")"
9595
]
9696
},
97+
{
98+
"cell_type": "markdown",
99+
"metadata": {},
100+
"source": [
101+
"Clone the oneDNN repo to current directory "
102+
]
103+
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": null,
107+
"metadata": {},
108+
"outputs": [],
109+
"source": [
110+
"!git clone https://github.com/oneapi-src/oneDNN.git"
111+
]
112+
},
97113
{
98114
"cell_type": "markdown",
99115
"metadata": {},
@@ -519,6 +535,105 @@
519535
"! chmod 755 run_blocked_v.sh;if [ -x \"$(command -v qsub)\" ]; then ./q run_blocked_v.sh; else ./run_blocked_v.sh; fi"
520536
]
521537
},
538+
{
539+
"cell_type": "markdown",
540+
"metadata": {},
541+
"source": [
542+
"### (Optional) BenchDNN with GPU\n",
543+
"\n",
544+
"In this optional section users can build benchdnn with GPU support and run GPU performance benchmarking."
545+
]
546+
},
547+
{
548+
"cell_type": "markdown",
549+
"metadata": {},
550+
"source": [
551+
"#### Script - build_gpu.sh\n",
552+
"The script **build_gpu.sh** encapsulates the compiler command and flags that will generate our benchDNN executable with DPCPP GPU runtime support."
553+
]
554+
},
555+
{
556+
"cell_type": "code",
557+
"execution_count": null,
558+
"metadata": {},
559+
"outputs": [],
560+
"source": [
561+
"%%writefile build_gpu.sh\n",
562+
"#!/bin/bash\n",
563+
"source /opt/intel/oneapi/setvars.sh --force\n",
564+
"cd oneDNN\n",
565+
"\n",
566+
"rm -rf build_gpu\n",
567+
"mkdir build_gpu\n",
568+
"cd build_gpu\n",
569+
" \n",
570+
"export CC=icx\n",
571+
"export CXX=icpx\n",
572+
"\n",
573+
"cmake -DDNNL_GPU_RUNTIME=SYCL ..\n",
574+
"make benchdnn"
575+
]
576+
},
577+
{
578+
"cell_type": "markdown",
579+
"metadata": {},
580+
"source": [
581+
"#### Submitting **build_gpu.sh** to the job queue\n",
582+
"Submit the **build_gpu.sh** to the job queue."
583+
]
584+
},
585+
{
586+
"cell_type": "code",
587+
"execution_count": null,
588+
"metadata": {},
589+
"outputs": [],
590+
"source": [
591+
"!chmod 755 q;chmod 755 build_gpu.sh;if [ -x \"$(command -v qsub)\" ]; then ./q build_gpu.sh; else ./build_gpu.sh; fi"
592+
]
593+
},
594+
{
595+
"cell_type": "markdown",
596+
"metadata": {},
597+
"source": [
598+
"#### Script - run_gpu.sh\n",
599+
"The script **run_gpu.sh** runs the benchdnn while invoking --engine=gpu:0 to run on the GPU:"
600+
]
601+
},
602+
{
603+
"cell_type": "code",
604+
"execution_count": null,
605+
"metadata": {},
606+
"outputs": [],
607+
"source": [
608+
"%%writefile run_gpu.sh\n",
609+
"#!/bin/bash\n",
610+
"echo \"########## Executing the run ##########\"\n",
611+
"export ONEDNN_VERBOSE=1\n",
612+
"export BENCHDNN_ROOT=oneDNN/build_gpu/tests/benchdnn\n",
613+
"export PROBLEM=g1mb256ic3ih227iw227oc96oh55ow55kh11kw11sh4sw4ph0pw0n\"alexnet:conv1\"\n",
614+
"\n",
615+
"./$BENCHDNN_ROOT/benchdnn --conv --engine=gpu:0 --mode=p --alg=direct $PROBLEM &> alexnet_gpu.log 2>&1\n",
616+
"\n",
617+
"echo \"########## Done with the run ##########\""
618+
]
619+
},
620+
{
621+
"cell_type": "markdown",
622+
"metadata": {},
623+
"source": [
624+
"#### Submitting **run_gpu.sh** to the job queue\n",
625+
"Submit the **run_gpu.sh** to the job queue."
626+
]
627+
},
628+
{
629+
"cell_type": "code",
630+
"execution_count": null,
631+
"metadata": {},
632+
"outputs": [],
633+
"source": [
634+
"! chmod 755 run_gpu.sh;if [ -x \"$(command -v qsub)\" ]; then ./q run_gpu.sh; else ./run_gpu.sh; fi"
635+
]
636+
},
522637
{
523638
"cell_type": "markdown",
524639
"metadata": {},
@@ -785,9 +900,9 @@
785900
],
786901
"metadata": {
787902
"kernelspec": {
788-
"display_name": "Python 3 (ipykernel)",
903+
"display_name": "Python 3 (Intel® oneAPI 2023.0)",
789904
"language": "python",
790-
"name": "python3"
905+
"name": "c009-intel_distribution_of_python_3_oneapi-beta05-python"
791906
},
792907
"language_info": {
793908
"codemirror_mode": {
@@ -799,7 +914,7 @@
799914
"name": "python",
800915
"nbconvert_exporter": "python",
801916
"pygments_lexer": "ipython3",
802-
"version": "3.9.12"
917+
"version": "3.9.15"
803918
},
804919
"nbTranslate": {
805920
"displayLangs": [

0 commit comments

Comments
 (0)