<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashutosh Hathidara on Medium]]></title>
        <description><![CDATA[Stories by Ashutosh Hathidara on Medium]]></description>
        <link>https://medium.com/@ashutosh1919?source=rss-82d1678654ba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mn-vvBn1k4BMOIvvB41K6A.png</url>
            <title>Stories by Ashutosh Hathidara on Medium</title>
            <link>https://medium.com/@ashutosh1919?source=rss-82d1678654ba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:59:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ashutosh1919/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating Neuro-Symbolic Sudoku Solver]]></title>
            <link>https://medium.com/analytics-vidhya/creating-neuro-symbolic-sudoku-solver-cc94c431d10b?source=rss-82d1678654ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc94c431d10b</guid>
            <category><![CDATA[sudoku-solver]]></category>
            <category><![CDATA[sudoku]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[symbolic-ai]]></category>
            <category><![CDATA[neurosymbolic-ai]]></category>
            <dc:creator><![CDATA[Ashutosh Hathidara]]></dc:creator>
            <pubDate>Wed, 01 Dec 2021 02:38:49 GMT</pubDate>
            <atom:updated>2022-02-25T17:01:45.940Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6JMir9xZnAZo14bzj9D3iw.png" /><figcaption>Neural Logic Machines Architecture (Ref: NLM Paper)</figcaption></figure><p>Solving a sudoku grid using a combination of Deep Learning and Symbolic AI is a very fancy idea. We have used one of such approaches here. The code for this model is made open-source and is available in the <a href="https://github.com/ashutosh1919/neuro-symbolic-sudoku-solver">GitHub repository</a>.</p><p>Deep learning models have achieved great success in tasks like speech recognition, image classification, machine translation, etc. But one of the disadvantages of deep learning is that it lacks systematicity. It can not understand basic rules for solving the problem. It tries to find the function that can approximate the solution.</p><p>If we talk about another side, <a href="https://arxiv.org/abs/2008.07912">Inductive logic programming</a> is a logic system that can naturally process symbolic rules in natural language understanding and reasoning. It has been developed for learning logical rules from examples. It creates a symbolic model which satisfies the positive examples and contradicts the negative ones. But ILP fails to scale for the complex problems due to exponentially large searching space.</p><p>Combining both of the above approaches reduces the disadvantages and creates very robust models. That is why it is called as Neuro-Symbolic domain in Artificial Intelligence. We have used one of such Neuro-Symbolic architecture called <a href="https://arxiv.org/pdf/1904.11694.pdf">Neural Logic Machines</a> to solve a sudoku puzzle.</p><h3>Neural Logic Machines</h3><p>The NLM is a neural realization of logic machines. Given a set of base predicates, grounded on a set of objects (the premises), NLMs sequentially apply first-order rules to draw conclusions, such as property about an object. It is a deep reinforcement learning architecture that uses boolean predicates computed on symbolic tensors. <a href="https://arxiv.org/pdf/1904.11694.pdf">NLM paper</a> presents multiple applications of solving basic systematic problems like sorting an array, finding the shortest path in a graph, solving block world puzzle, etc.</p><p>One may think that creating an RNN can solve these problems. Yes, it can. But RNN trained with array (to sort) of length 10 can not sort an array of length 15. This is where deep learning fails. The neural logic machine uses lifted rules which leverage the power of first-order logic to represent the system and then these first-order logic predicates grounded on a set of objects can be inputted into a neural network.</p><p>For example, if we consider a block world puzzle, we can extract a set of rules which defines the core systematicity of the puzzle as shown in the below figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O0ld3X6UPLYj94xqK6V-SA.png" /><figcaption>Fig. 1 Example set of rules for block world puzzle (Ref: NLM Paper)</figcaption></figure><p>We first calculate the boolean predicate rules for all objects in the system and then we input those into the NLM network.</p><p>For better understanding and as a prerequisite, we strongly suggest reading the <a href="https://arxiv.org/pdf/1904.11694.pdf">NLM paper</a> thoroughly before reading the next section. It will not only give clarity to the topic but will also introduce an entirely different symbolic domain in combination with neural networks.</p><h3>Creating Boolean Predicates for Sudoku</h3><p>As the rules describe, we need to fill all the empty cells in the sudoku grid with the number which doesn’t appear in the same row, column, and 3x3 sub-grid to solve the puzzle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*ORxDJxnaY7exQlirrlx-WA.jpeg" /><figcaption>Fig. 2 Sudoku puzzle</figcaption></figure><p>We can derive three basic rules to solve the puzzle. Let us suppose we want to put the number <strong><em>x</em></strong> in cell <strong><em>(r, c)</em></strong>. Below is a set of rules which must be satisfied to have a valid sudoku grid.</p><ol><li><strong><em>isRow(r, x)</em></strong>: Does row <strong><em>r</em></strong> contains number <strong><em>x</em></strong>?</li><li><strong><em>isColumn(c, x)</em></strong>: Does column <strong><em>c</em></strong> contains number <strong><em>x</em></strong>?</li><li><strong><em>isSubMatrix(r, c, x)</em></strong>: Does submatrix starting with row <strong><em>r</em></strong> and column <strong><em>c</em></strong> contains number <strong><em>x</em></strong>?</li></ol><p>Predicates <strong><em>isRow(r, x)</em></strong> and <strong><em>isColumn(c, x)</em></strong> are binary predicates whereas <strong><em>isSubMatrix(r, c, x)</em></strong> is a ternary predicate. We don’t have any nullary and unary predicate for the sudoku puzzle. We compute the above three predicates for each cell of the sudoku grid.</p><h3>Deep Reinforcement Learning &amp; Training</h3><p>We are using <a href="https://proceedings.neurips.cc/paper/1999/file/464d828b85b0bed98e80ade0a5c43b0f-Paper.pdf">Reinforce algorithm</a> with policy gradient calculation for training the model. NLM requires calculated above described boolean predicates as inputs.</p><p>We have used NLM with <strong><em>depth = 5</em></strong> and <strong><em>breadth = 3</em></strong>. The input layer of NLM has 4 nodes (first to input nullary predicates, second to input unary predicates, third to input binary predicates, and fourth to input ternary predicates). We stack the results of <strong><em>isRow(r, x)</em></strong> and <strong><em>isColumn(c, x)</em></strong> and input as binary predicates. Also, we input the results of <strong><em>isSubMatrix(r, c, x)</em></strong> as the ternary predicate. We don’t have nullary and unary predicates for this problem. So, we just pass <em>None</em> for those nodes.</p><p>Once we pass this data to NLM, the last layer computes the softmax and performs the action to generate the next state of the grid. These actions are performed using the action parameters which consist of the location of the empty cell and the target value to put in the cell. We perform the action by checking if the number produces a valid grid after putting that number in that particular cell. Based on that, we perform an action and return a reward. We are using the same reward scheme used in the original NLM project.</p><p>We have used a curriculum training scheme to train the model end to end. We are training the model for the grid with fewer empty cells first and then gradually increasing the number of empty cells.</p><p>Also, choosing action and performing action steps are not unbounded. They are bounded by Limited Proxy steps. It means that we have used hyperparameter as the maximum number of steps that the model can use to solve the sudoku grid.</p><h3>Evaluations &amp; Results</h3><p>We have trained the model with different numbers of limited proxy steps and below is the result that we obtained.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N5eZTM4Nu94IJ9xLQ7HTmg.png" /><figcaption>Fig. 3 Model evaluation results</figcaption></figure><p>From the above evaluations, we came to the conclusion that we have achieved the solvability of the sudoku puzzle using NLM.</p><p>We have structured our code to get the inference from the trained model. Below is how the inference result looks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pwrxyz4VSjgNjk4eewgerA.png" /><figcaption>Fig. 4 Inference results</figcaption></figure><p>Moreover, the model doesn’t just give a solved grid, it also gives the steps (trajectory) which it took for solving it which can lead to explanations.</p><h3>Future Work</h3><p>Based on the results and performance of our current work, the NLM model solves the sudoku grid but it doesn’t solve the sudoku grid in the optimal number of steps. We are planning to improve and develop more robust predicates which help the model solve the grid in the optimal number of steps.</p><p>The code of this model is made open-source and is available in the <a href="https://github.com/ashutosh1919/neuro-symbolic-sudoku-solver">GitHub repository</a>.</p><h3>References</h3><ol><li>Dong, Mao, Lin, Wang, Li, Zhou. Neural Logic Machines. 2019.</li><li>Sutton, McAllester, Singh, Mansour. Policy Gradient Methods for Reinforcement Learning with Function Approximation. 1999.</li><li>Wang, Donti, Wilder, Kolter. SATNet: Bridging Deep Learning and Logical Reasoning using a Differentiable Satisfiability Solver. 2019.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc94c431d10b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/creating-neuro-symbolic-sudoku-solver-cc94c431d10b">Creating Neuro-Symbolic Sudoku Solver</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Dockerized Flask + MongoDB Application]]></title>
            <link>https://medium.com/analytics-vidhya/creating-dockerized-flask-mongodb-application-20ccde391a?source=rss-82d1678654ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/20ccde391a</guid>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[dockerize]]></category>
            <dc:creator><![CDATA[Ashutosh Hathidara]]></dc:creator>
            <pubDate>Mon, 21 Sep 2020 07:15:14 GMT</pubDate>
            <atom:updated>2022-02-25T17:12:40.943Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ccRsJFp3b1q4dOTT5BwYA.png" /><figcaption>Dockerized Flask + MongoDB Application</figcaption></figure><p>To create these kinds of applications where more than two components are involved, the first thing that comes to our mind is that we should have one container running which will have both Flask server and MongoDB exposed. But in my opinion, this is not a good design. This design have below drawbacks.</p><ul><li>If the container crashes, we lose both Flask server and MongoDB.</li><li>Front-end applications accessing Flask and not requiring DB operations would not work.</li><li>Front-end applications accessing DB and not requiring Flask server would not work.</li></ul><p>The better and more optimised design would be to have two containers: one for Flask server, another is for MongoDB and link the container having Flask server with container having MongoDB hosted. In this way, we can overcome some very severe drawbacks of the first design.</p><p>If you are interested in learning it visually, I have created a video on my YouTube channel that you can take a look below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FRuaKvPq0Fzo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DRuaKvPq0Fzo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FRuaKvPq0Fzo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d90a91a1124f1c42cfebe9ece5fa7243/href">https://medium.com/media/d90a91a1124f1c42cfebe9ece5fa7243/href</a></iframe><p>Firstly, we can break this application problem in two parts: Flask and MongoDB. We need to create code sufficient to create dockerized Flask application and MongoDB hosted in container. We can do both independently. And the final steps would be to connect both of these codes.</p><p>Now, here is the simple roadmap to achieve what we want:</p><ul><li>Dockerized Flask application requires <strong><em>app.py</em></strong>, <strong><em>requirements.txt</em></strong>, <strong><em>Dockerfile</em></strong> and other files which is needed by <em>app.py</em> .</li><li>To host MongoDB over a container, we can pull already existing mongo image from <a href="https://hub.docker.com/_/mongo">here</a> and additionally we will also need <strong><em>init-db.js</em></strong> file where we will write JavaScript code to initialise the database with some tables when the MongoDB is hosted over a container. Note here that this file can be empty if you don’t want to initialise database at the time of creation.</li><li>We will connect Flask and MongoDB with <em>yml</em> file. So, we will also need <strong><em>docker-compose.yml</em></strong> file.</li></ul><p>Now, the things are bit simpler. We just have to follow the above roadmap.</p><h3><strong>Step 1: Creating Codebase for Flask Application</strong></h3><p>Here, I am going to have a small Flask application which will fetch the animals and their types from MongoDB. The code looks like below.</p><p>You can take a look at below code and you can observe that route <strong><em>“/”</em></strong> just returns a string which is just to check the code and route <strong><em>“/animals”</em></strong> will query the MongoDB running in another container. Note here that we have not created container with MongoDB so this code will not work now. But note the fact that Flask server will run on port <strong><em>5000</em></strong> and we are assuming that MongoDB is running on port <strong><em>27017</em></strong>.</p><p>We will also need <strong><em>requirements.txt</em></strong> which will contain the dependencies needed by <strong><em>app.py</em></strong> and <strong><em>Dockerfile</em></strong> to deploy the Flask app in container.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1ac6f09a75d6d8a1344dc35be026708/href">https://medium.com/media/d1ac6f09a75d6d8a1344dc35be026708/href</a></iframe><p>Of course, you can include functionality in the Flask app as per your requirements but make sure that the data which you are fetching is populated in MongoDB in below second step.</p><h3>Step 2: Creating Codebase for Hosting MongoDB on Docker Container</h3><p>We don’t need to pull docker image for mongo manually in this step. We can define the name of the image in the <strong><em>docker-compose.yml</em></strong> in Step 3. In this step, we just need to create the <strong><em>init-db.js</em></strong> file which will pre-populate the data at the time of the creation of MongoDB. The <strong><em>init-db.js</em></strong> file for this demo is as shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bcaecb12d7a04aac351d7bc11400a2f2/href">https://medium.com/media/bcaecb12d7a04aac351d7bc11400a2f2/href</a></iframe><p>You can observe that we have accessed a database <strong><em>“animal_db”</em></strong> and initialised collection named <strong><em>“animal_tb”</em></strong> inside this database with 3 elements.</p><h3><strong>Step 3: Creating docker-compose.yml file to link above components and deploy</strong></h3><p>We need to create <strong><em>docker-compose.yml</em></strong> file where we will define details of linking components and also the information which will be required by the codebase created in above two steps. Sample <strong><em>docker-compose.yml</em></strong> file is shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ce9c2c3c764ffe430daac595ccd6b3b/href">https://medium.com/media/1ce9c2c3c764ffe430daac595ccd6b3b/href</a></iframe><p>If you observe the above code. We have app in which we have defined a command to run the app. Also, we have linked <strong><em>db</em></strong> with the app where <strong><em>db</em></strong> is defined in the later part of the above code which is our MongoDB.</p><p>We have given image as name of image of MongoDB which is needed to be pulled from docker-hub. Note here that you can change the <strong><em>hostname</em></strong> and <strong><em>environment</em></strong> but make sure to change the same in <strong><em>app.py</em></strong> created in Step 1 and <strong><em>init-db.js</em></strong> created in Step 2.</p><p>Also, note here that we have exposed <strong><em>port 5000 for app</em></strong> and <strong><em>port 27017 for db</em></strong> as we are using the same in Flask app code.</p><p>Now, we are just one command away from deploying this whole application. Run below command wait till all the things are deployed.</p><p>$ docker-compose up</p><p>The Flask + MongoDB application is deployed and you can access the flask application as mentioned below.</p><p>If you are running docker desktop then you can access the flask app with <a href="http://localhost:5000/">http://localhost:5000/</a> but if you have installed docker with virtual-machine then you first need to get the IP for docker-machine. You can do that by executing the command “docker-machine default ip”. Here, default is the name of docker-machine. Now, you can access flask app with URL http://&lt;docker-machine-ip&gt;:5000/ .</p><p>If you want the code for the complete project, you can get the code in the GitHub repository <a href="https://github.com/ashutosh1919/flask_mongodb_dockerized_app">here</a>.</p><p>Thank you for reading this blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20ccde391a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/creating-dockerized-flask-mongodb-application-20ccde391a">Creating Dockerized Flask + MongoDB Application</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up GPU Support (CUDA & cuDNN) on Any Cloud/Native Instance for Deep Learning]]></title>
            <link>https://medium.com/@ashutosh1919/setting-up-gpu-support-cuda-cudnn-on-any-cloud-native-instance-for-deep-learning-fc3aef266071?source=rss-82d1678654ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc3aef266071</guid>
            <category><![CDATA[cuda]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[cudnn]]></category>
            <category><![CDATA[nvidia-driver]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ashutosh Hathidara]]></dc:creator>
            <pubDate>Fri, 18 Sep 2020 06:11:53 GMT</pubDate>
            <atom:updated>2020-09-18T06:11:53.142Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are working on cloud instance, first create cloud account for starting development of project. Create Virtual Machine Instance with following specifications.</p><ul><li>Ubuntu 16.04</li><li>GPU must be there. (Don’t use General Purpose instance)</li><li>At least 2vCPUs and 7.5 GB RAM.</li></ul><p>Connect the VM instance through terminal. (If the cloud you are using don’t provide terminal then use <a href="https://www.ssh.com/ssh/putty">puTTY</a>).</p><p>You can take a look at the CUDA &amp; cuDNN compatible versions <a href="https://www.tensorflow.org/install/source#tested_build_configurations">here</a> for different tensorflow versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SMIt07n1_izB5iNkznnhAg.png" /></figure><h3>Pre-Installation Actions</h3><p>First of all, you need to check that the system you are using has CUDA compatible GPU. You can do that using below command.</p><pre><strong>$</strong> lspci | grep -i nvidia</pre><p>You will also need latest version of GCC installed. Check version of GCC using:</p><pre><strong>$</strong> gcc --version</pre><p>If you don’t see GCC installed, install GCC as described <a href="https://gcc.gnu.org/install/">here</a>.</p><p>The kernel headers and development packages for the currently running kernel can be installed with:</p><pre><strong>$</strong> sudo apt-get install linux-headers-$(uname -r)</pre><p>If you are not using ubuntu, then you can download headers as per your system by referring <a href="https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#verify-kernel-packages">here</a>.</p><h3>Installing NVIDIA Graphics Drivers</h3><p>Note that different NVIDIA driver versions support different versions of CUDA &amp; cuDNN. You can take a look <a href="https://www.nvidia.com/Download/index.aspx">here</a> for appropriate driver version corresponding to CUDA version.</p><p>Here, I am going to illustrate CUDA-9.0 with NVIDIA driver 384. I am also assuming that the instance you are working with is Linux.</p><pre>$ sudo apt-get update<br>$ sudo apt-get install nvidia-384 nvidia-modprobe<br>$ sudo apt-get update</pre><h3>Installing CUDA-9.0</h3><p>Installing CUDA from runfile is actually a breeze, compared to apt-get which involves adding NVIDIA repos and messing up your configuration. The CUDA runfile installer can be downloaded from <a href="https://developer.nvidia.com/cuda-downloads">NVIDIA’s website</a>, or using wget in case you can’t find it easily on NVIDIA: (Note: the version I downloaded at first was 384.81 but NVidia constantly releases new minor versions.)</p><pre>$ cd<br>$ wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run</pre><p>What you download is a package the following three components:</p><ul><li>An NVIDIA driver installer, but usually of stale version</li><li>The actual CUDA installer</li><li>The CUDA samples installer</li></ul><p>I suggest extracting the above three components and executing 2 and 3 separately (remember we installed the driver ourselves already). To extract them, execute the runfile installer with — extract option:</p><pre>$ chmod +x cuda_9.0.176_384.81_linux-run<br>$ ./cuda_9.0.176_384.81_linux-run --extract=$HOME</pre><p>You should have unpacked three components:</p><ul><li>NVIDIA-Linux-x86_64–384.81.run (1. NVIDIA driver that we ignore)</li><li>cuda-linux.9.0.176–22781540.run (2. CUDA 9.0 installer)</li><li>cuda-samples.9.0.176–22781540-linux.run (3. CUDA 9.0 Samples).</li></ul><p>Execute the second one to install the CUDA Toolkit 9.0:</p><pre>$ sudo ./cuda-linux.9.0.176-22781540.run</pre><p>You now have to accept the license by scrolling down to the bottom (hit the d key on your keyboard) and enter accept. Next accept the defaults. To verify our CUDA installation, install the sample tests by:</p><pre>$ sudo ./cuda-samples.9.0.176-22781540-linux.run</pre><p>After the installation finishes, configure the runtime library.</p><pre>$ sudo bash -c &quot;echo /usr/local/cuda/lib64/ &gt; /etc/ld.so.conf.d/cuda.conf&quot;<br>$ sudo ldconfig</pre><p>It is also recommended for Ubuntu users to append string /usr/local/cuda/bin to system file /etc/environment so that nvcc will be included in $PATH. This will take effect after reboot. To do that, you just have to execute below command.</p><pre>$ sudo vim /etc/environment</pre><p>and then add :/usr/local/cuda/bin (including the &quot;:&quot;) at the end of the PATH=&quot;/blah:/blah/blah&quot; string (inside the quotes). After a reboot, let&#39;s test our installation by making and invoking our tests:</p><pre>$ cd /usr/local/cuda-9.0/samples<br>$ sudo make</pre><p>It’s a long process with many irrelevant warnings about deprecated architectures (sm_20 and such ancient GPUs). Note : If above command gives the error about the version conflict of GNU or gcc or g++ then install gcc-6 and g++-6 first and then try again. CUDA-9.0 requires gcc version 6 or below. After it completes, run deviceQuery and p2pBandwidthLatencyTest:</p><pre>$ cd /usr/local/cuda/samples/bin/x86_64/linux/release<br>$ ./deviceQuery</pre><p>After running deviceQuery, the system will check the installation and RESULT=PASS will be shown on screen. Cleanup : if ./deviceQuery works, remember to rm the 4 files (1 downloaded and 3 extracted).</p><h3>Install cuDNN-7.x</h3><p>The recommended way to install cuDNN 7.x is to download all 3 .deb files. I had previously recommended using the .tgz installation approach, but found out that it didn’t allow verification by running code samples (no way to install the code samples .deb after .tgz installation). Downloading the cuDNN file from <a href="https://developer.nvidia.com/rdp/cudnn-download">NVIDIA cuDNN website</a> can be very frustrating if you are using cloud VM through terminal because you can only download the file to your computer. You can&#39;t download it in VM by wget because it changes the configuration of .deb or .tgz file. But the solution here is we can download raw cuDNN .deb files from <a href="http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/">NVIDIA Repo</a> like we download raw .whl files for pip installing package. You can choose the link corresponding to the version of your preference.</p><p>Installing runtime library first,</p><pre>$ wget <a href="http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.1.3.16-1+cuda9.0_amd64.deb">http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.1.3.16-1+cuda9.0_amd64.deb</a><br>$ chmod +x libcudnn7_7.1.3.16-1+cuda9.0_amd64.deb<br>$ sudo -dpkg -i libcudnn7_7.1.3.16-1+cuda9.0_amd64.deb</pre><p>Installing developer library,</p><pre>$ wget <a href="http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.1.3.16-1+cuda9.0_amd64.deb">http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.1.3.16-1+cuda9.0_amd64.deb</a><br>$ chmod +x libcudnn7-dev_7.1.3.16-1+cuda9.0_amd64.deb<br>$ sudo -dpkg -i libcudnn7-dev_7.1.3.16-1+cuda9.0_amd64.deb</pre><p>Installing code samples. Note here that this file is of just 4 MB. So, if this doesn’t work then you can download this file in your computer, upload it to github and clone it in your cloud VM. You can also use scp or Cyberduck to upload it to cloud VM.</p><pre>$ wget http://apt.cs.uchicago.edu/pool/main/ c/cudnn/ libcudnn7-doc_7.1.3.16-1+cuda9.0_amd64.deb<br>$ chmod +x libcudnn7-doc_7.1.3.16-1+cuda9.0_amd64.deb<br>$ sudo -dpkg -i libcudnn7-doc_7.1.3.16-1+cuda9.0_amd64.deb</pre><p>Now we can verify the cuDNN installation (below is just the official guide, which surprisingly works out of the box):</p><ul><li>Copy the code samples somewhere you have write access: cp -r /usr/src/cudnn_samples_v7/ ~</li><li>Go to the MNIST example code: cd ~/mnistCUDNN. Path may change w.r.t. version of cuDNN you have installed.</li><li>Compile the MNIST example: make clean &amp;&amp; make.</li><li>Run the MNIST example: ./mnistCUDNN. If your installation is successful, you should see Test passed! at the end of the output.</li></ul><p>Finally, you also need to add CUDA in the $PATH environment variable. You can do so by executing following command. Note here that you have to give the version of CUDA that you have installed in place of cuda-9.0 .</p><pre><strong>$</strong> export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}</pre><p>In addition, when using the runfile installation method, the LD_LIBRARY_PATH variable needs to contain /usr/local/cuda-9.0/lib64 on a 64-bit system.</p><pre><strong>$</strong> export LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}</pre><h3>Check Your Installation &amp; Things to Consider</h3><p>To check the successful installation of drivers, CUDA &amp; cuDNN, run the following command in the terminal.</p><pre><strong>$</strong> nvidia-smi</pre><p>This will give you a table where on the top you can see the NVIDIA driver version and CUDA version. Note here that the CUDA version shown here may not be the version that you have installed because the CUDA version shown here is the version which the latest compatible to the shown driver version.</p><p>To see the current version of CUDA installed, run:</p><pre><strong>$</strong> nvcc --version</pre><p>Above command will show the installed CUDA version.</p><h3>Do NOT Install cuda-command-line-tools</h3><p>Contrary to the official TensorFlow installation docs, you don’t need to install cuda-command-line-tools because it’s already installed in this version of CUDA and cuDNN. If you apt-get it, you won’t find it.</p><h3>References</h3><ul><li><a href="https://medium.com/repro-repo/install-cuda-and-cudnn-for-tensorflow-gpu-on-ubuntu-79306e4ac04e">Zhanwen Chen’s Medium blog on CUDA Installation</a></li><li><a href="https://askubuntu.com/questions/1031197/cudnn-installation-on-ubuntu-server-16-04">Harvey’s answer on stackExchange</a></li><li><a href="http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/">NVIDIA compute repo for downloading raw files</a></li><li><a href="https://docs.microsoft.com/en-us/azure/">Azure Documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc3aef266071" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>