Check if tensorflow is using the GPU

If you run tensorflow in a docker console you can run the following code in your terminal:

docker exec b61a27999cb8 python3 -c "import tensorflow as tf; tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True))"

If you run a jupyter notebook you add the following line:

import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

Data persistence with Docker and tensorflow.

https://docs.docker.com/storage/

https://docs.docker.com/storage/volumes/

https://stackoverflow.com/questions/57341455/how-to-persist-my-notebooks-and-data-in-my-docker-image-container

docker run -it -p 8888:8888 -v /home/personal/Documents/tensorflowData:/tf/notebooks tensorflow/tensorflow:latest-gpu-jupyter

Change SOURCE_FOLDER and DEST_FOLDER accordingly (use absolute paths!).

Now if you navigate to localhost:8888 and create a notebook on DEST_FOLDER, it also should be available on SOURCE_FOLDER.

For tensorflow 2, the destination folder is /tf. You can create a folder of your choice, say: notebook, where you will save your file in your jupyter notebook. Those files will be available in the SOURCE_FOLDER you have set.

The changes in tensorflow-tutorials won’t be kept even if you choose it as your destination folder. You have to use another folder as detailed above.

Git: Revert commit and see what was change in a commit

Revert is usually a safe operation as it create a new commit.

git revert <SHA>

Before you revert a commit, you might want to check what was change in the commit as you might want to keep changes that were lumped in the commit:

git show SHA

If you made a commit in the wrong branch:

Go to proper branch and run: 

git cherry-pick <HASH> 

go to old branch, run: 

git revert <HASH>

In case of error see: https://blog.seobytes.eu/development/git-returns-is-a-merge-but-no-m-option-was-given/

Create remote repository from local (bitbucket/github)

Command to use:

Set up bitbucket ssh access.

Open a terminal in local directory and run:

git init
git checkout -b feature-branch

Create repository in Bitbucket and get the ssh url by clicking on the clone button.

In yout terminal run:

git remote add origin git@bitbucket.org:nicolashoquet/arcade.git

In case “origin” already exists, you can rename origin by running this command:

git remote rename origin https-origin

or use another name for origin (e.g. ssh-origin).

Set git ssh access for github or bitbucket

https://docs.github.com/en/github/getting-started-with-github/setting-your-username-in-git

Open a terminal

cd in the folder were you want to clone the repo:

$ cd directory/you/clone
$ git init
$ git config user.name “Your-Username” #can be different from your github username
$ git config user.email “your.email@example.com
$ ssh-keygen -t rsa -C “your.email@example.com

Enter file in which to save the key (/home/username/.ssh/id_rsa): /home/username.ssh/id_rsa

Copy the content of the id_rsa.pub in your Github settings in your profile.

Set Github local authentication to be able to clone and push:

http://kbroman.org/github_tutorial/pages/first_time.html

git stash

Save your current work on branch and return to a clean branch.

The following is copied from: https://git-scm.com/docs/git-stash

git-stash – Stash the changes in a dirty working directory away

SYNOPSIS

git stash list [<log-options>]
git stash show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]
git stash drop [-q|--quiet] [<stash>]
git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
git stash branch <branchname> [<stash>]
git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
	     [-u|--include-untracked] [-a|--all] [-m|--message <message>]
	     [--pathspec-from-file=<file> [--pathspec-file-nul]]
	     [--] [<pathspec>…​]]
git stash clear
git stash create [<message>]
git stash store [-m|--message <message>] [-q|--quiet] <commit>

DESCRIPTION

Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

The modifications stashed away by this command can be listed with git stash list, inspected with git stash show, and restored (potentially on top of a different commit) with git stash apply. Calling git stash without any arguments is equivalent to git stash push. A stash is by default listed as “WIP on branchname …​”, but you can give a more descriptive message on the command line when you create one.

The latest stash you created is stored in refs/stash; older stashes are found in the reflog of this reference and can be named using the usual reflog syntax (e.g. stash@{0} is the most recently created stash, stash@{1} is the one before it, stash@{2.hours.ago} is also possible). Stashes may also be referenced by specifying just the stash index (e.g. the integer n is equivalent to stash@{n}).

Uninstall docker from Ubuntu

If you installed docker with snap:

simple uninstall:

sudo snap remove docker

and to disable automatic snapshot:

sudo snap remove --purge docker

If after reinstalling docker you have the following error:

bash: /snap/bin/docker: No such file or directory

you need to run

hash docker

and

hash docker-compose

Installation instruction:

https://docs.docker.com/engine/install/ubuntu/

Note that if you installed an old version with snap, you should follow the instruction provided in this article.

https://docs.docker.com/compose/install/

Log integer in beanshell and get integer from variables

Issue:

log.info() returns the following error in JMeter beanshell:

 Error in method invocation: Method info( int ) not found in class'org.apache.logging.slf4j.Log4jLogger'

Solution:

The error message indicates you are trying to pass an integer in the log.info() method. To prevent this issue, convert the integer to the type String using:

String SomeString = new Integer.toString(somInteger);

Similarly, numerals are passed as strings in JMeter variables, to make arithmetic operation on them, you’ll need to convert them to integer using:

int someInteger = new Integer.parseInt(someString);

Example use:

vars.put("test", new Integer(i).toString());

yarn : ERROR: There are no scenarios; must have at least one. On Ubuntu

Issue: The following error is displayed when running yarn in the same directory as the package.jsnon file:

00h00m00s 0/0: : ERROR: There are no scenarios; must have at least one.

Solution:

this is the wrong yarn, ubuntu install cmdtest.

Run:

sudo apt remove cmdtest
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list 
sudo apt update 
sudo apt install yarn