Wednesday 26 October 2022

How to install conda inside a Dockerfile?

(everything must put under one line inside Dockerfile)

# to install conda and torch
ENV CONDA_DIR /opt/conda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
RUN /bin/bash ~/miniconda.sh -b -p /opt/conda
RUN . /root/.bashrc && \
    /opt/conda/bin/conda init bash && \
    /opt/conda/bin/conda create -n torch110 python=3.8 pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch-lts -c nvidia -y


bash.sh in the host:-

export PYTHONPATH=/usr/local/opencv4/python3
export LD_LIBRARY_PATH=/usr/local/cuda/compat/lib.real:/opt/tritonserver/lib:/usr/src/tensorrt/lib:/opt/jarvis/lib/:/opt/kenlm/lib/:/opt/tritonserver/lib/pytorch/:/usr/local/cuda/compat/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/lib:/usr/local/server2012/lib:/opt/conda/envs/torch110/lib/
eval "$(conda shell.bash hook)"
conda activate torch110
cd /data/example
python main.py
conda deactivate

 

 

Tuesday 25 October 2022

How to correct python indentation using vim?

Ref: https://iqbalnaved.wordpress.com/2013/12/09/vim-tip-how-to-fix-python-exception-indentationerror/


The problem is usually with mixup in tabs and spaces –

Solution 1

1. Apply following command in Vim to highlight tabs, spaces and other whitespace differently.

1
:set listchars=tab:>-,trail:-,eol:$ list

2. Apply the following to set correct width

1
:set shiftwidth=4 tabstop=4 expandtab

3. running

1
:retab

to fix the problem,Vim automatically fixes all indentation space and tab mix ups.

Solution 2

1. set ‘list’, so that you can see the whitespace and change.

Have the following mapping in .vimrc for this:

nnoremap    <F2> :<C-U>setlocal lcs=tab:>-,trail:-,eol:$ list! list? <CR>

2. Ensure ‘expandtab’ is reset, check using following command –

:verbose set ts? et?

3. To expand all leading spaces (wider than ‘tabstop’), use retab.

retab takes a range, so specify % to mean “the whole file”.

:set tabstop=4      " To match the python file
:set noexpandtab    " Use tabs, not spaces
:%retab!            " Retabulate the whole file

Wednesday 5 October 2022

How to hide os login page user list in ubuntu20?

ref: https://ubuntuhandbook.org/index.php/2021/06/hide-user-accounts-ubuntu-20-04-login-screen/