Friday, January 12, 2018

tensorflow c++ compiling problems

Problem 1

fatal error: third_party/eigen3/unsupported/Eigen/CXX11/Tensor: No such file or directory

if you pip install using virtual environment, the include files are not copied.

Solution

1. Dirty one. Install tensorflow globally.
2. The including files will be copied to
 /usr/local/lib/python2.7/dist-packages/tensorflow/
Thus, we only need to copy them to ~/tensorflow/include python2.7.
The source files are stored in
tensorflow-1.5.0-rc0/third_party/eigen3/unsupported/Eigen/CXX11


Problem 2

fatal error: nsync_cv.h: No such file or directory
fatal error: nsync_mu.h: No such file or directory

Solution

1. modify source c++ file
find /usr/local/lib/python2.7/dist-packages/tensorflow/ -name "nsync_mu.h"
/usr/local/lib/python2.7/dist-packages/tensorflow/include/external/nsync/public/nsync_mu.h

modify line 25 and 26 to include right path in /usr/local/lib/python2.7/dist-packages/tensorflow/include/tensorflow/core/platform/default/mutex.h

2. 
or modify makefile to add include path
add nsync_cv.h include:-I$TF_INC/external/nsync/public
below is official demo
TF_INC=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
TF_LIB=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')
g++ -std=c++11 -shared zero_out.cc -o zero_out.so -fPIC -I$TF_INC -I$TF_INC/external/nsync/public -L$TF_LIB -ltensorflow_framework -O2

Problem 3

Using tensorboard
  File "/home/jinglu/tensorflow/bin/tensorboard", line 7, in <module>
    from tensorboard.main import run_main

Solution

pip install tb-nightly

Problem 4


Undefined symbol: _ZTIN10tensorflow8OpKernelE

Solution

add the flags in g++
-L $TF_LIB -ltensorflow_framework 

Thursday, January 11, 2018

Add/Delete sudo user


Steps to Create a New Sudo User



  1. Log in to your server as the root user.
    • ssh root@server_ip_address
  2. Use the adduser command to add a new user to your system.
    Be sure to replace username with the user that you want to create.
    • adduser username
    • Set and confirm the new user's password at the prompt. A strong password is highly recommended!
      Set password prompts:
      Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
    • Follow the prompts to set the new user's information. It is fine to accept the defaults to leave all of this information blank.
      User information prompts:
      Changing the user information for username Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n]
  3. Use the usermod command to add the user to the sudo group.
    • usermod -aG sudo username
    By default, on Ubuntu, members of the sudo group have sudo privileges.
  4. Test sudo access on new user account
    • Use the su command to switch to the new user account.
      • su - username
    • As the new user, verify that you can use sudo by prepending "sudo" to the command that you want to run with superuser privileges.
      • sudo command_to_run
    • For example, you can list the contents of the /root directory, which is normally only accessible to the root user.
      • sudo ls -la /root
    • The first time you use sudo in a session, you will be prompted for the password of the user account. Enter the password to proceed.
      Output:
      [sudo] password for username:
      If your user is in the proper group and you entered the password correctly, the command that you issued with sudo should run with root privileges.

How To Delete a User

In the event that you no longer need a user, it is best to delete the old account.
You can delete the user itself, without deleting any of his or her files by typing this as root:
deluser newuser
If you are signed in as another non-root user with sudo privileges, you could instead type:
sudo deluser newuser
If, instead, you want to delete the user's home directory when the user is deleted, you can issue the following command as root:
deluser --remove-home newuser
If you're running this as a non-root user with sudo privileges, you would instead type:
sudo deluser --remove-home newuser
If you had previously configured sudo privileges for the user you deleted, you may want to remove the relevant line again by typing:
visudo
Or use this if you are a non-root user with sudo privileges:
sudo visudo
root    ALL=(ALL:ALL) ALL
newuser ALL=(ALL:ALL) ALL   # DELETE THIS LINE
This will prevent a new user created with the same name from being accidentally given sudo privileges.