<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Azhan Mohammed</title>
    <description>The latest articles on DEV Community by Azhan Mohammed (@sheikhazhanmohammed).</description>
    <link>https://dev.to/sheikhazhanmohammed</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F246194%2F068ee490-0166-45b6-a002-ef6a30822cfa.png</url>
      <title>DEV Community: Azhan Mohammed</title>
      <link>https://dev.to/sheikhazhanmohammed</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sheikhazhanmohammed"/>
    <language>en</language>
    <item>
      <title>Setting up Google Colab for Deep Learning</title>
      <dc:creator>Azhan Mohammed</dc:creator>
      <pubDate>Wed, 09 Jun 2021 22:13:20 +0000</pubDate>
      <link>https://dev.to/sheikhazhanmohammed/setting-up-google-colab-for-deep-learning-1ion</link>
      <guid>https://dev.to/sheikhazhanmohammed/setting-up-google-colab-for-deep-learning-1ion</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://colab.research.google.com/notebooks/intro.ipynb#recent=true"&gt;Google Colaboratory&lt;/a&gt; or Colab is a free service provided by Google that allows a person to run Python notebooks without having to install python on their systems. Colab provides a user with numerous features, the most important of them being:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No need to configure for basic notebooks&lt;/li&gt;
&lt;li&gt;Free and easy GPU access&lt;/li&gt;
&lt;li&gt;Easily sharing of codes and link the notebooks to &lt;a href="https://github.com"&gt;GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Loading datasets straight from your Google Drive and saving notebooks/ trained models to your drive too.
Google Colab also comes with a Pro feature, you can learn more about the details of Colab Pro from &lt;a href="https://colab.research.google.com/signup"&gt;here&lt;/a&gt;.
In this blog post we shall discuss about setting up your Colab notebook to get started with Machine Learning or Deep Learning development.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installing dependencies
&lt;/h2&gt;

&lt;p&gt;While Colab usually comes pre-installed with most of the basic dependencies like Tensorflow, PyTorch, scikit-learn, pandas and many more, there are chances that you have to install external packages at times. You can do that using the &lt;code&gt;!pip install&lt;/code&gt; command. For example we can install the &lt;a href="https://github.com/qubvel/ttach"&gt;ttach&lt;/a&gt; library which is used for augmentation of images during test phase. This can be done using:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!pip install library-name&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Running the cell will yeild an output like:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DLKlRVMp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dur71n8z6u7ln4kg0zvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DLKlRVMp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dur71n8z6u7ln4kg0zvg.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
This way we can install custom libraries as per our needs.&lt;/p&gt;
&lt;h2&gt;
  
  
  Mounting Google Drive
&lt;/h2&gt;

&lt;p&gt;You can mount your Google Drive using a simple the simple script given below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from google.colab import drive
drive.mount('/content/drive')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Upon running this you will get a link that will redicrect you to select the account whose google drive you want to mount. Select the account, accept the the permission request and copy the code that appears on the screen and paste that in the dialog box and press enter. Your Google Drive is now mounted and you can access it via the files menu on your left. The output would look something like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fcFmsgKe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/duo4q0xdwcu9noayf7vv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fcFmsgKe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/duo4q0xdwcu9noayf7vv.png" alt="image"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Cloning GitHub Repositories
&lt;/h2&gt;

&lt;p&gt;At times you might need to clone your GitHub repository to your Colab library to work on complex projects that utilize multiple scripts. That can be done using &lt;code&gt;!git clone link-to-repository&lt;/code&gt;&lt;br&gt;
Running the cell would clone the repository to your working directory.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GqNyalay--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pcgoyl7m8g9yzjw7snc3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GqNyalay--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pcgoyl7m8g9yzjw7snc3.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
You can also clone a repository to your google drive if you have mounted it. That is done using &lt;code&gt;!git clone link-to-repository path-to-drive&lt;/code&gt;. The sample output would look like:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nDxyu3Nv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1hfljsw2pxoxal481rs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nDxyu3Nv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1hfljsw2pxoxal481rs.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessing GPU runtime
&lt;/h2&gt;

&lt;p&gt;One of the best features of Colab is the free GPU runtime it provides. You can enable your GPU runtime by:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to Runtime
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d-ZFwvYd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2x66zgnv8win79oo7asx.png" alt="image"&gt;
&lt;/li&gt;
&lt;li&gt;Select Change runtime type
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bdb_ecYk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vlh5w2jduolou98xcsq3.png" alt="image"&gt;
&lt;/li&gt;
&lt;li&gt;Select GPU from the drop down menu and click on save
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ej2lDqCp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/frqnocxyi7koupulpequ.png" alt="image"&gt;
That's it, now you can use your GPU runtime provided by Colab.
You can also check which GPU you are provided using &lt;code&gt;!nvidia-smi&lt;/code&gt;.
The output shows GPU memory you are consuming and other details as well.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6EdNQ90q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfuxt2wldkgltq3aoodo.png" alt="image"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This concludes our discussion for setting up Colab to run Machine Learning and Deep Learning applications. Now you can easily clone GitHub repositories to your drive and execute them using GPU runtime without having to install Python on your local machine.&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
