Category Archives: Python

How to Resolve The Error “Illegal instruction (core dumped)” when Running “import tensorflow” in a Python Program

There are several ways to install TensorFlow on Ubuntu. The easiest way is to install via pip. Unfortunately, this easy installation may result in a bumpy first time experience of running TensorFlow. Consider the following one line Python script:

$ python -c 'import tensorflow as tf;'

This should be where the excitement begins, the moment where conviction about the new era of AI-powered banalities starts to bloom. Yet, the reality can be unexpectedly different. Executing the command may immediately raise this very infamous error:

Illegal instruction (core dumped)

This means that TensorFlow has crashed even before it does anything. What a surprise!

The good thing is that we can run gdb to debug Python and start analyzing the call stack. But what’s even better is that we can save the brilliance for later. This error has been repeatedly reported and has conveniently sat on its fame for a while, as reflected on the issue page. Continue reading

How to Install Jupyter Notebook as Service for Tensor Flow and Deep Learning on Ubuntu 16.04

When developing a deep-learning system, especially during the modeling stage, a lot of trials and errors can be involved in evolving the codebase. The easy remedy to reduce errors will be by using a robust IDE that provides productivity-boosting features such as code completion, method definition, codestyle suggestion, advanced debugging, user-friendly UI, and so forth.

Another element for better development experience is interactivity. Instead of writing the whole source code and evaluate everything, it is arguably more productive to write the code in small steps, with one line as the smallest unit, and evaluate the code up to the last line written. This kind of mechanism is possible for scripting language where the codes are interpreted. Node JS for example has a feature named Read-Eval-Print Loop (REPL) that enables someone to write Javascript code with Node JS and has it evaluated on the go. Deep learning algorithms and systems are often developed in Python, another interpreted language. Similar initiative also exists for Python in the forms of interactive shell and “notebook”. A notebook is an interactive environment, normally with web GUI support, where someone can combine code execution, text, rich media, charting and other types of data visualization. A popular notebook for Python is Jupyter Notebook, which was formerly known as IPython Notebook.

In this article, we will go into more details about Jupyter Notebook installation and configuration on Ubuntu 16.04. However, it’s important to note that the configuration depends on some pre-requisites. This article is the continuation of the previous article about TensorFlow installation. Please make sure you have read the article to understand the pre-requisites, otherwise some steps explained in this article may not work. Continue reading

What Object Categories / Labels Are In COCO Dataset?

One important element of deep learning and machine learning at large is dataset. A good dataset will contribute to a model with good precision and recall. In the realm of object detection in images or motion pictures, there are some household names commonly used and referenced by researchers and practitioners. The names in the list include Pascal, ImageNet, SUN, and COCO. In this post, we will briefly discuss about COCO dataset, especially on its distinct feature and labeled objects.

tl;dr The COCO dataset labels from the original paper and the released versions in 2014 and 2017 can be viewed and downloaded from this repository. Continue reading

Resolving Error “ImportError: No module name named hypothesis”

When running the test script “relu_op_test.py” to verify Caffe2 installation, you may encounter this error “ImportError: No module name named hypothesis”. Let’s take a look at the content of the script to get some idea about the root cause.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from caffe2.python import core
from hypothesis import given
import hypothesis.strategies as st
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.mkl_test_util as mu
import numpy as np

import unittest

class TestRelu(hu.HypothesisTestCase):

    @given(X=hu.tensor(),
           engine=st.sampled_from(["", "CUDNN"]),
           **mu.gcs)
    def test_relu(self, X, gc, dc, engine):
        op = core.CreateOperator("Relu", ["X"], ["Y"], engine=engine)
        # go away from the origin point to avoid kink problems
        X += 0.02 * np.sign(X)
        X[X == 0.0] += 0.02
        self.assertDeviceChecks(dc, op, [X], [0])
        self.assertGradientChecks(gc, op, [X], 0, [0])


if __name__ == "__main__":
    unittest.main()

Continue reading