One place for hosting & domains

      How To Install and Use TensorFlow on Ubuntu 18.04


      TensorFlow is open-source machine learning software used to train neural networks.TensorFlow’s neural networks are expressed in the form of stateful dataflow graphs. Each node in the graph represents the operations performed by neural networks on multi-dimensional arrays. These multi-dimensional arrays are commonly known as “tensors,” hence the name TensorFlow.

      TensorFlow is a deep learning software system. It works well for information retrieval, as demonstrated by Google in how they do search ranking in their machine learning artificial intelligence system, RankBrain. TensorFlow can perform image recognition, as shown in Google’s Inception, as well as human language audio recognition. It’s also useful in solving other problems not specific to machine learning, such as partial differential equations.

      The TensorFlow architecture allows for deployment on multiple CPUs or GPUs within a desktop, server, or mobile device. There are also extensions for integration with CUDA, a parallel computing platform from Nvidia. This gives users who are deploying on a GPU direct access to the virtual instruction set and other elements of the GPU that are necessary for parallel computational tasks.

      In this tutorial, we’ll install TensorFlow’s “CPU support only” version. This installation is ideal for people looking to install and use TensorFlow, but who don’t have an Nvidia graphics card or don’t need to run performance-critical applications.

      You can install TensorFlow several ways. Each method has a different use case and development environment:

      • Python and Virtualenv: In this approach, you install TensorFlow and all of the packages required to use TensorFlow in a Python virtual environment. This isolates your TensorFlow environment from other Python programs on the same machine.
      • Native pip: In this method, you install TensorFlow on your system globally. This is recommended for people who want to make TensorFlow available to everyone on a multi-user system. This method of installation does not isolate TensorFlow in a contained environment and may interfere with other Python installations or libraries.
      • Docker: Docker is a container runtime environment and completely isolates its contents from preexisting packages on your system. In this method, you use a Docker container that contains TensorFlow and all of its dependencies. This method is ideal for incorporating TensorFlow into a larger application architecture already using Docker. However, the size of the Docker image will be quite large.

      In this tutorial, you’ll install TensorFlow in a Python virtual environment with virtualenv. This approach isolates the TensorFlow installation and gets things up and running quickly. Once you complete the installation, you’ll validate your installation by running a short TensorFlow program and then use TensorFlow to perform image recognition.


      Before you begin this tutorial, you’ll need the following:

      Step 1 — Installing TensorFlow

      In this step we are going to create a virtual environment and install TensorFlow.

      First, create a project directory. We’ll call it tf-demo for demonstration purposes, but choose a directory name that is meaningful to you:

      Navigate to your newly created tf-demo directory:

      Then create a new virtual environment called tensorflow-dev, for instance. Run the following command to create the environment:

      • python3 -m venv tensorflow-dev

      This creates a new tensorflow-dev directory which will contain all of the packages that you install while this environment is activated. It also includes pip and a standalone version of Python.

      Now activate your virtual environment:

      • source tensorflow-dev/bin/activate

      Once activated, you will see something similar to this in your terminal:

      (tensorflow-dev)username@hostname:~/tf-demo $

      Now you can install TensorFlow in your virtual environment.

      Run the following command to install and upgrade to the newest version of TensorFlow available in PyPi:

      • pip install --upgrade tensorflow

      TensorFlow will install, and you should get output that indicates that the install along with any dependent packages was successful.


      ... Successfully installed absl-py-0.7.1 astor-0.7.1 gast-0.2.2 grpcio-1.19.0 h5py-2.9.0 keras-applications-1.0.7 keras-preprocessing-1.0.9 markdown-3.0.1 mock-2.0.0 numpy-1.16.2 pbr-5.1.3 protobuf-3.7.0 setuptools-40.8.0 tensorboard-1.13.1 tensorflow-1.13.1 tensorflow-estimator-1.13.0 termcolor-1.1.0 werkzeug-0.15.0 wheel-0.33.1 ... Successfully installed bleach-1.5.0 enum34-1.1.6 html5lib-0.9999999 markdown-2.6.9 numpy-1.13.3 protobuf-3.5.0.post1 setuptools-38.2.3 six-1.11.0 tensorflow-1.4.0 tensorflow-tensorboard-0.4.0rc3 werkzeug-0.12.2 wheel-0.30.0

      You can deactivate your virtual environment at any time by using the following command:

      To reactivate the environment later, navigate to your project directory and run source tensorflow-dev/bin/activate.

      Now that you have installed TensorFlow, let’s make sure the TensorFlow installation works.

      Step 2 — Validating Installation

      To validate the installation of TensorFlow, we are going to run a simple program in TensorFlow as a non-root user. We will use the canonical beginner’s example of “Hello, world!” as a form of validation. Rather than creating a Python file, we’ll create this program using Python's interactive console.

      To write the program, start up your Python interpreter:

      You will see the following prompt appear in your terminal:


      This is the prompt for the Python interpreter, and it indicates that it’s ready for you to start entering some Python statements.

      First, type this line to import the TensorFlow package and make it available as the local variable tf. Press ENTER after typing in the line of code:

      Next, add this line of code to set the message “Hello, world!”:

      • hello = tf.constant("Hello, world!")

      Then create a new TensorFlow session and assign it to the variable sess:

      Note: Depending on your environment, you might see this output:


      2019-03-20 16:22:45.956946: W tensorflow/core/platform/] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. 2019-03-20 16:22:45.957158: W tensorflow/core/platform/] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2019-03-20 16:22:45.957282: W tensorflow/core/platform/] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2019-03-20 16:22:45.957404: W tensorflow/core/platform/] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2019-03-20 16:22:45.957527: W tensorflow/core/platform/] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.

      This tells you that you have an instruction set that has the potential to be optimized for better performance with TensorFlow. If you see this, you can safely ignore it and continue.

      Finally, enter this line of code to print out the result of running the hello TensorFlow session you’ve constructed in your previous lines of code:

      In Python 3, will return a byte string, which will be rendered as b'Hello, world!' if you runprint( In order to returnHello, world!as a string, let’s add thedecode()` method.

      • print(

      You’ll see this output in your console:


      Hello, world!

      This indicates that everything is working and that you can start using TensorFlow.

      Exit the Python interactive console by pressing CTRL+D or typing quit().

      Next, let’s use TensorFlow’s image recognition API to get more familiar with TensorFlow.

      Step 3 — Using TensorFlow for Image Recognition

      Now that TensorFlow is installed and you’ve validated it by running a simple program, we can take a look at TensorFlow’s image recognition capabilities.

      In order to classify an image you need to train a model. Then you need to write some code to use the model. To learn more about machine learning concepts, consider reading “An Introduction to Machine Learning.”

      TensorFlow provides a repository of models and examples, including code and a trained model for classifying images.

      Use Git to clone the TensorFlow models repository from GitHub into your project directory:

      • git clone

      You will receive the following output as Git checks out the repository into a new folder called models:


      Cloning into 'models'... remote: Enumerating objects: 32, done. remote: Counting objects: 100% (32/32), done. remote: Compressing objects: 100% (26/26), done. remote: Total 24851 (delta 17), reused 12 (delta 6), pack-reused 24819 Receiving objects: 100% (24851/24851), 507.78 MiB | 32.73 MiB/s, done. Resolving deltas: 100% (14629/14629), done. Checking out files: 100% (2858/2858), done.

      Switch to the models/tutorials/image/imagenet directory:

      • cd models/tutorials/image/imagenet

      This directory contains the file which uses TensorFlow to recognize images. This program downloads a trained model from on its first run. Downloading this model requires that you have 200MB of free space available on disk.

      In this example, we will classify a pre-supplied image of a Panda. Execute this command to run the image classifier program:

      You’ll receive output similar to this:


      giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca (score = 0.89107) indri, indris, Indri indri, Indri brevicaudatus (score = 0.00779) lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens (score = 0.00296) custard apple (score = 0.00147) earthstar (score = 0.00117)

      You have classified your first image using the image recognition capabilities of TensorFlow.

      If you’d like to use another image, you can do this by adding the -- image_file argument to your python3 command. For the argument, you would pass in the absolute path of the image file.


      In this tutorial, you have installed TensorFlow in a Python virtual environment and validated that TensorFlow works by running through some examples. You now possess tools that make it possible for you to explore additional topics including Convolutional Neural Networks and Word Embeddings.

      TensorFlow's programmer’s guide provides a useful resource and reference for TensorFlow development. You can also explore Kaggle, a competitive environment for practical application of machine learning concepts that pit you against other machine learning, data science, and statistics enthusiasts. They have a robust wiki where you can explore and share solutions, some of which are on the cutting edge of statistical and machine learning techniques.

      Source link

      Spring Clean Your Website With This 13-Point Checklist

      The birds are chirping and the blossoms blooming, and you know what that means: it’s time to tackle your spring cleaning. Winter’s thaw is an annual reminder to clear out the clutter — and not just in your garage. Websites spawn their own digital dust bunnies and need an annual scrub to keep things running smoothly.

      This spring, take time to air out your website. Visitors will appreciate — and reward — a freshly scrubbed, updated site. Superpower your spring cleaning with this checklist of chores and your website will be sure to pass any white-glove inspection.

      1. Update Copyright and Time References

      Sure, the info stuffed in your website’s footer can feel like a fussy detail, but it’s one that can speak volumes about the attention you pay to your content. Visitors are sure to question the validity and functionality of an out-of-date website, so exude relevancy and timeliness by making this quick update. Go a step further and ensure your copyright date is always current by adding a few lines of code.

      2. Renew Domain Names

      Don’t let your domain disappear — renew your registration now or set a calendar reminder to do it before it expires.

      3. Check for Broken Links

      Like dusting, this tedious chore is best checked off more than once a year, but hey, we all get busy. Broken links will frustrate your visitors, repel customers, and damage your search engine rankings. If you haven’t hunted down these pesky pests recently, find yourself a link checker and tracking. There are a number of tools that can help here, but we recommend Screaming Frog.

      4. Check and Update Contact Information

      There’s little more frustrating than returned or unanswered email. Make sure your customers’ queries are going to the right inbox by double checking and, if necessary, updating your email address and other contact information: phone, fax, addresses, social media accounts, etc. Make sure the info for all your brick-and-mortar locations (if you have them) is present and accounted for. While you’re at it, delete any superfluous or unused email accounts, and don’t forget to remove every reference to them from your website.

      5. Test Functionality

      Fill out any forms, take any surveys, sign up for every email list offered on your site, and make sure the process is simple, intuitive, and most importantly, functional. Check that comments work on your blog, and don’t forget to test-drive your checkout process from shopping cart to deposit of money into the correct account. Fix any bugs and consider ways you can smooth out the process.

      6. Update Prices and Review Inventory

      Operation and manufacturing costs fluctuate through the year, so take a look at your numbers and check your prices for fairness to the customer — and to your profit margin. Also, take a second look at the products you have listed for sale. Any slow movers that need to be rethought, repriced, or retired? Make sure to remove any discontinued products from your site.

      7. Review Consistency

      Scroll through your content to ensure that fonts, image sizes and style, and copywriting and grammar style are consistent throughout your website. Tidy up any inconsistencies to ensure a professional look. And while you’re at it, check for relevancy and timeliness too, especially in introductory posts, popular content, and product descriptions. Repurpose or delete dated content.

      Be Awesome on the Internet

      Join our monthly newsletter for tips and tricks to build your dream website!

      8. Update Bios

      Keep your website feeling fresh by updating your bio and polishing up the “About Us” page. Double check any key stats or numbers listed on this page as well. Don’t forget to update staff positions and job duties that may have changed in the past year, so credit is given where it’s due and customer queries are addressed to the right person.

      9. Note Your News

      Nothing feels more stale on a website than old news, and little is more repelling than a “what’s new” post from 2013. When’s the last time you’ve updated your news page? There’s no time like the present: write a quick and catchy update, or consider nixing this page if you can’t keep it timely. If you have a calendar or events page, delete past events and update with current information.

      10. Update Policies

      The policy page is an easy one to fall through the cracks, so make sure to pull it out of the cupboard and give it some love this spring. Check that your company’s current practices are accurately and clearly represented — make sure nothing is overlooked — and make changes as needed.

      11. Review Analytics

      Take a look at Google Analytics and sift out trends. Determine which pages are frequented the most, and which are getting a bit moldy. Polish up your popular posts and consider how you can get more mileage out of them — a social media post or campaign, perhaps? As for the dustier pages, bring in more visitors with links and shoutouts in more popular posts, repurpose the content, or consider axing them entirely. If the pages you want people to see aren’t getting enough traffic, it’s time to rethink how the content is teased and the information presented.

      12. Evaluate Calls to Action (CTAs)

      Are your “subscribe,” “donate here,” and “buy now” links drawing enough attention? Rethink how you can shine up your calls to action so your website can better accomplish its purpose and clinch new customers.

      13. Review Your Hosting Plan

      After you’ve dusted off the details, take a step back and look at the place your website calls home. Is your current hosting plan working for you and your customers? Take a closer look at your analytics: are you seeing your website traffic grow over time? If you started out with shared hosting and are attracting more and more visitors, it might be time to upgrade to a plan that will enhance your site’s performance and stability. Consider whether your website would benefit from a VPS or a dedicated server.

      Source link

      The Linode Backup Service

      Updated by Linode

      Written by Alex Fornuto

      The Linode Backup Service

      The Linode Backup Service is a subscription service add-on that automatically performs daily, weekly, and biweekly backups of your Linode. It’s affordable, easy to use, and provides peace of mind. This guide explains how to enable and schedule your backups, make a manual backup snapshot, restore from a backup, and disable the Backup Service.


      Pricing is per Linode and varies depending upon your Linode’s plan:

      Standard Plans

      Service Backups Hourly Rate Backups Monthly
      Linode 1GB $0.003/hr $2/mo
      Linode 2GB $0.004/hr $2.50/mo
      Linode 4GB $0.008/hr $5/mo
      Linode 8GB $0.016/hr $10/mo
      Linode 16GB $0.03/hr $20/mo
      Linode 32GB $0.06/hr $40/mo
      Linode 64GB $0.12/hr $80/mo
      Linode 96GB $0.18/hr $120/mo
      Linode 128GB $0.24/hr $160/mo
      Linode 192GB $0.36/hr $240/mo

      High Memory Plans

      Service Backups Hourly Rate Backups Monthly
      Linode 24GB $0.0075/hr $5/mo
      Linode 48GB $0.015/hr $10/mo
      Linode 90GB $0.03/hr $20/mo
      Linode 150GB $0.06/hr $40/mo
      Linode 300GB $0.12/hr $80/mo

      Enable the Backup Service

      Use the Linode Cloud Manager to enable the Backup Service on a Linode. Here’s how:

      1. Log in to the Linode Cloud Manager.

      2. From the Linodes page, select the Linode you want to back up.

      3. Click the Backups tab.

        Enable Linode Backups by navigating to to the individual Linode's backup menu.

      4. Click Enable Backups.

      The Linode Backup Service is now enabled for the selected Linode.

      Auto Enroll New Linodes in the Backup Service

      You can automatically enroll all new Linodes in the Backup Service. To do so, click the Account link in the sidebar, then select the Global Settings tab.

      In the Backup Auto Enrollment panel, click on the switch to enable backups on all new Linodes.

      Auto enroll all new Linodes in the Backup Service by navigating to the Global Settings tab in the Account settings and enabling Backups.


      Enabling this setting does not retroactively enroll any previously created Linodes in the Backup Service.

      Manage Backups

      You’ll manage your backups with a simple web interface in the Linode Cloud Manager. There’s no software to install, and there are no commands to run. Just log in to the Linode Cloud Manager, navigate to the Linodes page by clicking on the link in the sidebar, select a Linode, and then click the Backups tab. The backups interface is shown below.

      The Linode Backup Service interface

      1. A list of available backups. Listed in this view are the date created, the label, how long the backup took to be created, the disks imaged, and the size of the resulting image.

      2. Manually create a backup by taking a manual snapshot. For more information, see the Take a Manual Snapshot section.

      3. Configure backup schedule settings. For more information, see the Schedule Backups section.

      4. Cancel backups. After cancelling your backups you will have to wait 24 hours before you can re-enable them again.

      How Linode Backups Work

      Backups are stored on a separate system in the same data center as your Linode. The space required to store the backups is not subtracted from your storage space. You can store four backups of your Linode, three of which are automatically generated and rotated:

      • Daily backup: Automatically initiated daily within the backup window you select. Less than 24 hours old.
      • Current week’s backup: Automatically initiated weekly within the backup window, on the day you select. Less than 7 days old.
      • Last week’s backup: Automatically initiated weekly within the backup window, on the day you select. Between 8 and 14 days old.
      • Manual Snapshot: A user-initiated snapshot that stays the same until another snapshot is initiated.

      The daily and weekly backups are automatically erased when a new backup is performed. The Linode Backup Service does not keep automated backups older than 8 – 14 days.

      Schedule Backups

      You can configure when automatic backups are initiated. Here’s how:

      1. From the Linodes page, select the Linode.

      2. Click the Backups tab.

      3. Under Settings, select a time interval from the Time of Day menu. The Linode Backup Service will generate all backups between these hours.

      4. Select a day from the Day of Week menu. This is the day whose backup will be promoted to the weekly slot. The back up will be performed within the time period you specified in step 3.

      5. Click Save Changes.

      The Linode Backup Service will backup your Linode according to the schedule you specified.

      Take a Manual Snapshot

      You can make a manual backup of your Linode by taking a snapshot. Here’s how:

      1. From the Linodes page, select the Linode.

      2. Click the Backups tab.

      3. Under Manual Snapshot, give your snapshot a name and click Take Snapshot.


        Taking a new snapshot will overwrite a previously saved snapshot.

      The Linode Backup Service initiates the manual snapshot. Creating the manual snapshot can take several minutes, depending on the size of your Linode and the amount of data you have stored on it. Other Linode Cloud Manager jobs for this Linode will not run until the snapshot job has been completed.

      Restore from a Backup

      This section shows how to restore a backup to a new Linode, or to an existing Linode.

      Restoring a backup will create a new configuration profile and a new set of disks on your Linode. The restore process does not restore single files or directories automatically. Restoring particular files can be done by completing a normal restore, copying the files off of the new disks, and then removing the disks afterward.


      The size of the disk(s) created by the restore process will only be slightly larger than the total size of the files restored. This means that the disk(s) created will be ‘full’.

      Some applications, like databases, need some amount of free unused space inside the disk in order to run. As a result, you may want to increase your disk(s) size after the restore process is completed.

      To restore a backup to a different data center, first restore to a Linode in the same data center, creating a new one if necessary. Once the restore is complete, use the Clone tab to copy the disk(s) to a Linode in a different data center.

      Restore to a New Linode

      This section covers how to restore a backup to a new Linode that does not have any disks deployed to it. The new Linode will be located in the same data center. If you instead wish to restore your backup to an existing Linode, see the next section.

      1. From the Linodes page, select the Linode whose backups you intend to restore, and then click on the Backups tab. Select the more options ellipsis next to the backup you would like to restore, and click Deploy New Linode.

        Click on the ellipsis menu icon to restore to a new Linode.

      2. You will be taken to the Create New Linode screen. The Create from Backup tab will already be selected for you, as will the fields corresponding to the Linode and backup that you are restoring from. Choose a Linode plan, enter a label for the new Linode, select any other options you prefer, and click Create. The new Linode will be created with the same password and SSH keys (if any) as the original.

        The backup disks and configuration profiles will be restored to the Linode you selected. Watch the notifications area for updates on the process. Restoring from a backup can take several minutes depending on the size of your Linode and the amount of data you have stored on it.

      Restore to an Existing Linode

      You can restore a backup to any Linode located in the same data center, even if the target does not have the Backup Service enabled. To restore a backup to an existing Linode, you will need to make sure that you have enough storage space that is not currently assigned to disk images.


      If you are attempting to restore a disk to the same Linode the backup was created from, the restoration process will not delete the original disk for you. Manually delete the original disk to make room for the backup, if desired.

      1. From the Linodes page, select the Linode whose backups you intend to restore, and then click on the Backups tab. Observe the size of the backup you would like to restore, which is visible in the Space Required column. You will need at least this amount of unallocated disk space on the target Linode to complete the restore.

      2. Select the more options ellipsis next to the backup you would like to restore, and click Restore to Existing Linode.

        Click on the ellipsis menu icon to restore to an existing Linode.

      3. A menu will open with the Linodes that you can restore to. Select a Linode and click Restore.

        Select the Linode you would like to restore your backup to.

        You will be notified if you do not have enough space on your Linode to restore your backup. Optionally, you can choose to overwrite the Linode you are restoring to.

      4. If the amount of unallocated space available is greater than the size of the backup, you can proceed with restoring. If the amount of unallocated space is less than the size of the backup, you can stop the restoration workflow, resize your existing disks on the target Linode to make room for it, and then come back to the restore page after the disk resize operation has finished.


        In some cases, you will not be able to shrink your disks enough to fit the restored backup. As an alternative, you can change your Linode’s plan to a higher tier that offers more disk space.
      5. From the Restore to Existing Linode menu, click Restore.

        Your backup will begin restoring to your Linode, and you can monitor its progress in the notifications area. Note that the time it takes to restore your backup will vary depending upon the restore size, and the number of files being restored.

      Boot from a Backup

      After the backup has been restored, the disks and configuration profiles will be available to the destination Linode you selected. Select the restored configuration profile and reboot your Linode to start up from the restored disks:

      1. From the Linodes page, select the Linode that you restored the backup to. Navigate to the Settings tab and open the Advanced Configurations panel.

      2. Select the more options ellipsis next to the configuration profile that was restored and select Boot This Config.

        Navigate to the Advanced Configurations section of your Linode's Settings tab.

      The Linode will start from the backup disks. Monitor the notifications area for progress.

      Cancel the Backup Service

      You can cancel the Backup Service at any time. From your Linode’s details page, choose the Backups tab and click the Cancel Backups link at the bottom of the page. Cancelling the service will remove your saved backups from the Linode platform.


      There are some limitations to what the Linode Backup Service can back up. Here are some things you should be aware of:

      • The Backup Service must be able to mount your disks. If you’ve created partitions, configured full disk encryption, or made other changes that prevent us from mounting the disk as a filesystem, you will likely not be able to use the Linode Backup Service. The backup system operates at the file level, not at the block level.
      • Because the Backup Service is file-based, the number of files stored on disk will impact both the time it takes for backups and restores to complete, and your ability to successfully take and restore backups. Customers who need to permanently store a large number of files may want to archive bundles of smaller files into a single file, or consider other backup services.


        The percentage of customers who may run into this limitation is low. If you are not sure if this limitation applies to you, please contact Linode Support.
      • Backups taken of ext4 or ext3 filesystems will be restored as ext4. Backups taken of other mountable filesystem types will have their contents restored using ext4.

      • Files that have been modified but have the same size and modify time will not be considered “changed” during a subsequent backup. ACLs and extended attributes are not tracked.

      • The Backup Service uses a snapshot of your disks to take consistent backups while your Linode is running. This method is very reliable, but can fail to properly back up the data files for database services like MySQL. If the snapshot occurs during a transaction, the database’s files may be backed up in an unclean state. We recommend scheduling routine dumps of your database to a file on the filesystem. The resulting file will then be backed up, allowing you to restore the contents of the database if you need to restore from a backup.

      Find answers, ask questions, and help others.

      This guide is published under a CC BY-ND 4.0 license.

      Source link