Valus kurk

Mul on valus vaadata külmikusse, kus lebab kurk. Kurk on nii valus, et mul on kõrini. Valu ulatub kõrini ja valust on kõrini. Külm kapp on õlut täis, sest õlu on jahe ja tegi kapa külmaks. Õlu tegi…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Deploying Deep Learning Django app to Google Cloud Platform

Deploying a simple Django application may seem easy on a publicly (free) available hosting website, which to some extent is true. However, the struggle begins when you are working on a deep learning-based application. I have deployed multiple models on free hosting website (Heroku) but I had to pull an all-nighter to finally understand that it’s impossible to host a TensorFlow (not the lite ones) based model to these freely available hosting websites due to the limitation of slug size (500 MB - upload size/compressed file size). Hence, I have decided to write a post on how to host a Tensorflow based app to Google Cloud Platform using a few easy steps.

This is one of the techniques (probably the simplest one) of hosting your Django application to GCP.

Creating a Virtual Machine on Google Cloud Platform

Installing necessary packages (Python3, pip, wget, etc)

“make altinstall” will help us install additional versions of Python on our OS.

2. Check the version if it’s properly installed or not.

3. Set your Python version to Python 3.6.10 with priority as 1 as follows:

Sometimes it might happen that your Python version is installed in a different folder (most of the times in your /usr/local/lib directory). To set the current python version to Python 3.6 from that directory, use the below command.

4. Set Python 3.6.10 to auto mode to use this as default python version

Enter Selection as 1 to set 3.6 as your default Python version.

5. Now install pip and wget as follows:

Upgrade pip if required or else you can also use the default installed version.

Preparing your Django app for hosting

4. Change your directory to the cloned project

5. Now, install requirements.txt from your project

It’s gonna take some time to install all the dependencies (mainly your Tensorflow==2.1.0 (421 MB) 😛 Patience is the key guys ✌️).

6. Finally, run your server on the instance as follows:

nohup command will help you keep your server running even if you close the terminal, whereas |tee & will keep the server running in the background while disconnecting from stdout. Hence, there won’t be any unnecessary output generated which will use your space. However, if you are experiencing any issues and would like to check the error then use the below command:

This will print all the errors to your terminal.

Congratulations ! You have successfully deployed your Deep Learning-based Django project to GCP.

Some additional FYI thing

portpid is a unique number (23/234/4567/12446) assigned to http (80) port, which you can figure out from netstat command.

2. If you face issues related to installing Tensorflow or any other large libraries due to size, as all the installation is done at cache level for the first time. Use this:

3. If you would like to check the size metrics for your VM machine, use this:

This will help you keep track of disk space (used and available), cache, and other memory-related stuffs.

I will be posting on how to develop a Django application with easy steps soon. Till then Enjoy coding !! 👍

Add a comment

Related posts:

Who is the holdeman reporter

A holdeman reporter is a term used in the printing and publishing industry to describe someone who reports on the production process. They are responsible for ensuring that all aspects of the…

How Many People Will Read My Article?

That got me thinking. I bet other writers have the same question, and it is a complicated one to answer, but I will give it a go. Let us start with the basics. If you have 100 followers, there is a…

Best Ad Networks for CPM Banner in 2022

There are a ton of ways to monetize a website and that’s thanks to the advance of technology. If you specifically want to advertise with CPM banners, then this article is perfect for you. When we…