<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gpu &#8211; richliu&#039;s blog</title>
	<atom:link href="https://richliu.com/tag/gpu/feed/" rel="self" type="application/rss+xml" />
	<link>https://richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Fri, 23 Jun 2023 09:01:04 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Run Keras or TensorFlow in WSL2 with Nvidia GPU</title>
		<link>https://richliu.com/2023/06/23/5238/run-keras-or-tensorflow-in-wsl2-with-nvidia-gpu/</link>
					<comments>https://richliu.com/2023/06/23/5238/run-keras-or-tensorflow-in-wsl2-with-nvidia-gpu/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Fri, 23 Jun 2023 07:17:00 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[CUDA]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[Keras]]></category>
		<category><![CDATA[Nvidia]]></category>
		<category><![CDATA[Tensorflow]]></category>
		<category><![CDATA[WSL2]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=5238</guid>

					<description><![CDATA[<p>When this article is finished, it will still be unable  [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2023/06/23/5238/run-keras-or-tensorflow-in-wsl2-with-nvidia-gpu/">Run Keras or TensorFlow in WSL2 with Nvidia GPU</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When this article is finished, it will still be unable to run Keras or TensorFlow within Conda or a virtual environment. This is because TensorFlow/Keras will display an error message similar to the one below (cut):</p>



<pre class="wp-block-preformatted">Node: 'model_3/conv1d_24/Conv1D' 
DNN library is not found. 	 [[{{node model_3/conv1d_24/Conv1D}}]] [Op:__inference_train_function_34509]</pre>



<p>It seems that there may be compatibility issues between the versions of TensorFlow/Keras installed outside of Conda and those installed within Conda. But it maybe also cause by tensorflow 2.12 has issue, please re-install 2.10 and try again . <br />Specified version can work well cuDNN 8.9, CUDA 11.8 and TensorFlow 2.10. <br />Here is how to re-install tensorflow 2.10 instruction.<br /></p>



<span id="more-5238"></span>



<pre class="wp-block-preformatted">pip uninstall tensorflow
pip install tensorflow-gpu
pip install tensorflow-gpu==2.10 </pre>



<p><br />ref. <br /><a href="https://github.com/tensorflow/tensorflow/issues/60101" target="_blank" rel="noreferrer noopener">TensorFlow 2.12.0 WSL2 GPU support</a></p>



<p>Have tried someother way, all of them doesn&#8217;t work when you use 2.12 tensorflow. Don&#8217;t try this. ex:</p>



<pre class="wp-block-preformatted">sudo cp cuda/include/cudnn*.h   /anaconda3/envs/&lt;your environment here&gt;/include
sudo cp cuda/lib64/libcudnn*    /anaconda3/envs/&lt;your environment here&gt;/lib
sudo chmod a+r /usr/local/cuda/include/cudnn*.h    /anaconda3/envs/&lt;your environment here&gt;/lib/libcudnn*</pre>



<p>ref.<br /><a href="https://stackoverflow.com/questions/55256671/how-to-install-latest-cudnn-to-conda" target="_blank" rel="noreferrer noopener">How to install latest cuDNN to conda?</a></p>



<h2 class="wp-block-heading">Install</h2>



<h3 class="wp-block-heading">CUDA</h3>



<p>Suppose it already install WSL2 on your system, please follow the <a href="https://docs.nvidia.com/cuda/wsl-user-guide/index.html" target="_blank" rel="noreferrer noopener">CUDA on WSL User Guide</a> to install WSL, for Tensorflow 2.12, suggestion CUDA version is 11.8. <a href="https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Linux&amp;target_arch=x86_64&amp;Distribution=WSL-Ubuntu&amp;target_version=2.0&amp;target_type=deb_local" target="_blank" rel="noreferrer noopener">Can be found here CUDA Toolkit 11.8 Downloads</a></p>



<pre class="wp-block-preformatted">wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda</pre>



<h3 class="wp-block-heading">cuDNN</h3>



<p>It still needs to install CUDNN, follow this instruction to download CUDNN 8.9.x, <a href="https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-linux" target="_blank" rel="noopener">Installing cuDNN on Linux</a>. Download cuDNN needs to register Nvidia account. <br />Download address : <a href="https://developer.nvidia.com/rdp/cudnn-download" target="_blank" rel="noreferrer noopener">cuDNN Download</a>, it has cuDNN for CUDA 12 and CUDA 11, download for CUDA 11. </p>



<h3 class="wp-block-heading">Add Path to System Path</h3>



<p>Put following seting into ~/.bashrc, thus it can update when get bash console </p>



<pre class="wp-block-preformatted">export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH</pre>



<h3 class="wp-block-heading">Follow tensorflow install guide to install tensorflow.</h3>



<p><a href="https://www.tensorflow.org/install/pip#windows-wsl2_1" target="_blank" rel="noreferrer noopener">Tensorflow step by step instructions for WSL2</a></p>



<h2 class="wp-block-heading">Python Virtual Environment</h2>



<p>if use virtual venv, it also can work, just need to install right version tensorflow. and it needs to configure cuDNN path on activate script </p>



<pre class="wp-block-preformatted">vim &lt;path to venv&gt;/bin/activate

# After get VIRTUAL_ENV, include the CUDNN path
export VIRTUAL_ENV

CUDNN_PATH=$(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"))
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$VIRTUAL_ENV/lib/:$CUDNN_PATH/lib
</pre>



<h2 class="wp-block-heading">Reference</h2>



<p><a href="https://hackmd.io/@Kailyn/HkSTXL9xK" target="_blank" rel="noreferrer noopener">WSL2 安裝 CUDA Toolkit、cuDNN</a></p>



<p><br /></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2023/06/23/5238/run-keras-or-tensorflow-in-wsl2-with-nvidia-gpu/">Run Keras or TensorFlow in WSL2 with Nvidia GPU</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2023/06/23/5238/run-keras-or-tensorflow-in-wsl2-with-nvidia-gpu/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>GRUB 開機會停在 Load Ramdisk 的問題</title>
		<link>https://richliu.com/2018/02/24/2212/grub-%e9%96%8b%e6%a9%9f%e6%9c%83%e5%81%9c%e5%9c%a8-load-ramdisk-%e7%9a%84%e5%95%8f%e9%a1%8c/</link>
					<comments>https://richliu.com/2018/02/24/2212/grub-%e9%96%8b%e6%a9%9f%e6%9c%83%e5%81%9c%e5%9c%a8-load-ramdisk-%e7%9a%84%e5%95%8f%e9%a1%8c/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sat, 24 Feb 2018 01:09:46 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[5775c]]></category>
		<category><![CDATA[boot]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[z97]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=2212</guid>

					<description><![CDATA[<p>背景是換新主機版之後, 偶爾開機的時候可以 Load 到 EFI 的 Loader, 看的到 GURB, 但是 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2018/02/24/2212/grub-%e9%96%8b%e6%a9%9f%e6%9c%83%e5%81%9c%e5%9c%a8-load-ramdisk-%e7%9a%84%e5%95%8f%e9%a1%8c/">GRUB 開機會停在 Load Ramdisk 的問題</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>背景是換新主機版之後, 偶爾開機的時候可以 Load 到 EFI 的 Loader, 看的到 GURB, 但是進去之後會停在 Load Ramdisk &#8230;..</p>
<p>主機版是 Z97-A-USB31<br />
CPU 是 i7-5775C 內建的 GPU<br />
<span id="more-2212"></span></p>
<p>現在看起來在 GRUB 開機時加上參數 nomodeset 就可以了.</p>
<p>網路上找來對 nomodeset 的說明</p>
<pre lang="text">
The newest kernels have moved the video mode setting into the kernel. 
So all the programming of the hardware specific clock rates and 
registers on the video card happen in the kernel rather than in 
the X driver when the X server starts.. This makes it possible 
to have high resolution nice looking splash (boot) screens and 
flicker free transitions from boot splash to login screen. 
Unfortunately, on some cards this doesn't work properly and you 
end up with a black screen. Adding the nomodeset parameter 
instructs the kernel to not load video drivers and use BIOS
 modes instead until X is loaded.
</pre>
<p>也就是說 modeset 已經搬到 kernel 了. 但是有時在 kernel 的 modeset 會有問題, 這就是告訴 kernel 用 grub 的設定, 直到 X 啟動</p>
<p>ref.<br />
https://askubuntu.com/questions/716957/what-do-the-nomodeset-quiet-and-splash-kernel-parameters-mean/716966</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2018/02/24/2212/grub-%e9%96%8b%e6%a9%9f%e6%9c%83%e5%81%9c%e5%9c%a8-load-ramdisk-%e7%9a%84%e5%95%8f%e9%a1%8c/">GRUB 開機會停在 Load Ramdisk 的問題</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2018/02/24/2212/grub-%e9%96%8b%e6%a9%9f%e6%9c%83%e5%81%9c%e5%9c%a8-load-ramdisk-%e7%9a%84%e5%95%8f%e9%a1%8c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
