{"id":10715,"date":"2023-12-26T07:08:40","date_gmt":"2023-12-26T07:08:40","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=10715"},"modified":"2023-12-26T07:08:40","modified_gmt":"2023-12-26T07:08:40","slug":"installation-3","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2023\/12\/26\/installation-3\/","title":{"rendered":"Installation"},"content":{"rendered":"\n<p>Now, that you have got enough insights on the capabilities of Caffe2, it is time to experiment Caffe2 on your own. To use the pre-trained models or to develop your models in your own Python code, you must first install Caffe2 on your machine.<\/p>\n\n\n\n<p>On the installation page of Caffe2 site which is available at the link\u00a0https:\/\/caffe2.ai\/docs\/getting-started.html\u00a0you would see the following to select your platform and install type.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tutorialspoint.com\/caffe2\/images\/installation_page.jpg\" alt=\"Installation Page\"\/><\/figure>\n\n\n\n<p>As you can see in the above screenshot,&nbsp;<strong>Caffe2<\/strong>&nbsp;supports several popular platforms including the mobile ones.<\/p>\n\n\n\n<p>Now, we shall understand the steps for&nbsp;<strong>MacOS installation<\/strong>&nbsp;on which all the projects in this tutorial are tested.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">MacOS Installation<\/h2>\n\n\n\n<p>The installation can be of four types as given below \u2212<\/p>\n\n\n\n<ul>\n<li>Pre-Built Binaries<\/li>\n\n\n\n<li>Build From Source<\/li>\n\n\n\n<li>Docker Images<\/li>\n\n\n\n<li>Cloud<\/li>\n<\/ul>\n\n\n\n<p>Depending upon your preference, select any of the above as your installation type. The instructions given here are as per the Caffe2 installation site for&nbsp;<strong>pre-built binaries<\/strong>. It uses Anaconda for&nbsp;<strong>Jupyter environment<\/strong>. Execute the following command on your console promptpip install torch_nightly -f https:\/\/download.pytorch.org\/whl\/nightly\/cpu\/torch_nightly.html<\/p>\n\n\n\n<p>In addition to the above, you will need a few third-party libraries, which are installed using the following commands \u2212conda install -c anaconda setuptools conda install -c conda-forge graphviz conda install -c conda-forge hypothesis conda install -c conda-forge ipython conda install -c conda-forge jupyter conda install -c conda-forge matplotlib conda install -c anaconda notebook conda install -c anaconda pydot conda install -c conda-forge python-nvd3 conda install -c anaconda pyyaml conda install -c anaconda requests conda install -c anaconda scikit-image conda install -c anaconda scipy<\/p>\n\n\n\n<p>Some of the tutorials in the Caffe2 website also require the installation of&nbsp;<strong>zeromq<\/strong>, which is installed using the following command \u2212conda install -c anaconda zeromq<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Windows\/Linux Installation<\/h2>\n\n\n\n<p>Execute the following command on your console prompt \u2212conda install -c pytorch pytorch-nightly-cpu<\/p>\n\n\n\n<p>As you must have noticed, you would need Anaconda to use the above installation. You will need to install the additional packages as specified in the&nbsp;<strong>MacOS installation<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing Installation<\/h2>\n\n\n\n<p>To test your installation, a small Python script is given below, which you can cut and paste in your Juypter project and execute.from caffe2.python import workspace import numpy as np print (&#8220;Creating random data&#8221;) data = np.random.rand(3, 2) print(data) print (&#8220;Adding data to workspace &#8230;&#8221;) workspace.FeedBlob(&#8220;mydata&#8221;, data) print (&#8220;Retrieving data from workspace&#8221;) mydata = workspace.FetchBlob(&#8220;mydata&#8221;) print(mydata)<\/p>\n\n\n\n<p>When you execute the above code, you should see the following output \u2212Creating random data [[0.06152718 0.86448082] [0.36409966 0.52786113] [0.65780886 0.67101053]] Adding data to workspace &#8230; Retrieving data from workspace [[0.06152718 0.86448082] [0.36409966 0.52786113] [0.65780886 0.67101053]]<\/p>\n\n\n\n<p>The screenshot of the installation test page is shown here for your quick reference \u2212<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tutorialspoint.com\/caffe2\/images\/testing_installation.jpg\" alt=\"Testing Installation\"\/><\/figure>\n\n\n\n<p>Now, that you have installed Caffe2 on your machine, proceed to install the tutorial applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tutorial Installation<\/h2>\n\n\n\n<p>Download the tutorials source using the following command on your console \u2212git clone &#8211;recursive https:\/\/github.com\/caffe2\/tutorials caffe2_tutorials<\/p>\n\n\n\n<p>After the download is completed, you will find several Python projects in the&nbsp;<strong>caffe2_tutorials<\/strong>&nbsp;folder in your installation directory. The screenshot of this folder is given for your quick perusal.\/Users\/yourusername\/caffe2_tutorials<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tutorialspoint.com\/caffe2\/images\/tutorial_installation.jpg\" alt=\"Tutorial Installation\"\/><\/figure>\n\n\n\n<p>You can open some of these tutorials to see what the&nbsp;<strong>Caffe2 code<\/strong>&nbsp;looks like. The next two projects described in this tutorial are largely based on the samples shown above.<\/p>\n\n\n\n<p>It is now time to do some Python coding of our own. Let us understand, how to use a pre-trained model from Caffe2. Later, you will learn to create your own trivial neural network for training on your own dataset.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now, that you have got enough insights on the capabilities of Caffe2, it is time to experiment Caffe2 on your own. To use the pre-trained models or to develop your models in your own Python code, you must first install Caffe2 on your machine. On the installation page of Caffe2 site which is available at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[761],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/10715"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=10715"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/10715\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=10715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=10715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=10715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}