Skip to content

Commit c9c3d04

Browse files
ulken94Haneol Kim
and
Haneol Kim
authored
Add tensor decomposition (#24)
* Add tensor decomposition * Add tensor decomposition * Add tensor decomposition * Add tensor decomposition * Modify logging procedure * Modify gitignore file Co-authored-by: Haneol Kim <[email protected]>
1 parent dd537d3 commit c9c3d04

39 files changed

+1668
-150
lines changed

.flake8

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# This is an example .flake8 config, used when developing *Black* itself.
2-
# Keep in sync with setup.cfg which is used for source packages.
3-
41
[flake8]
5-
ignore = E203, E266, E501, W503
2+
ignore = E501, ANN101, D414, W503
63
max-line-length = 88
7-
max-complexity = 18
8-
select = B,C,E,F,W,T4,B9
4+
docstrings-convention = google

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ dmypy.json
131131
# saved files while running
132132
save/*
133133

134+
# Decomposed files
135+
decompose/*
136+
134137
# caches
135138
wandb
136139
.DS_Store
140+
141+
# Ignore Docker setting
142+
.last_exec_cont_id.txt

Dockerfile

Lines changed: 85 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,85 @@
1-
FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04
2-
3-
# Install some basic utilities
4-
RUN apt-get update && apt-get install -y \
5-
curl \
6-
ca-certificates \
7-
sudo \
8-
git \
9-
bzip2 \
10-
libx11-6 \
11-
&& rm -rf /var/lib/apt/lists/*
12-
13-
# Create a working directory
14-
RUN mkdir /app
15-
WORKDIR /app
16-
17-
# Create a non-root user and switch to it
18-
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
19-
&& chown -R user:user /app
20-
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
21-
USER user
22-
23-
# All users can use /home/user as their home directory
24-
ENV HOME=/home/user
25-
RUN chmod 777 /home/user
26-
27-
# Install Miniconda and Python 3.7
28-
ENV CONDA_AUTO_UPDATE_CONDA=false
29-
ENV PATH=/home/user/miniconda/bin:$PATH
30-
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py37_4.8.2-Linux-x86_64.sh \
31-
&& chmod +x ~/miniconda.sh \
32-
&& ~/miniconda.sh -b -p ~/miniconda \
33-
&& rm ~/miniconda.sh \
34-
&& conda install -y python==3.7 \
35-
&& conda clean -ya
36-
37-
# CUDA 10.2-specific steps and required library settings
38-
RUN conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit -c pytorch \
39-
&& conda install -c conda-forge progressbar2 \
40-
&& conda clean -ya
41-
42-
COPY requirements.txt $HOME/
43-
COPY requirements-dev.txt $HOME/
44-
RUN pip install -r $HOME/requirements.txt
45-
RUN pip install -r $HOME/requirements-dev.txt
46-
47-
# Set the default command to python3
48-
CMD ["python3"]
1+
FROM nvcr.io/nvidia/tensorrt:21.05-py3
2+
3+
LABEL maintainer="Jongkuk Lim <[email protected]>"
4+
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
ENV TZ=Asia/Seoul
7+
8+
ARG UID=1000
9+
ARG GID=1000
10+
RUN groupadd -g $GID -o user && useradd -m -u $UID -g $GID -o -s /bin/bash user
11+
12+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
13+
RUN apt-get update && apt-get install -y sudo dialog apt-utils tzdata
14+
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && echo "user:user" | chpasswd && adduser user sudo
15+
16+
WORKDIR /home/user
17+
USER user
18+
19+
# Install Display dependencies
20+
RUN sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev && sudo apt-get -y install jq
21+
22+
# Install pip3 and C++ linter
23+
RUN sudo apt-get install -y clang-format cppcheck
24+
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py --force-reinstall && python3 -m pip install --upgrade pip
25+
RUN python3 -m pip install wheel cpplint
26+
27+
# Install doxygen for C++ documentation
28+
RUN sudo apt-get update && sudo apt-get install -y flex bison && sudo apt-get autoremove -y
29+
RUN git clone -b Release_1_9_2 https://github.com/doxygen/doxygen.git \
30+
&& cd doxygen \
31+
&& mkdir build \
32+
&& cd build \
33+
&& cmake -G "Unix Makefiles" .. \
34+
&& make -j `cat /proc/cpuinfo | grep cores | wc -l` \
35+
&& sudo make install
36+
37+
# Install PyTorch CUDA 11.1
38+
RUN python3 -m pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
39+
40+
# Install other development dependencies
41+
COPY ./requirements-dev.txt ./
42+
RUN python3 -m pip install -r requirements-dev.txt
43+
RUN rm requirements-dev.txt
44+
45+
# Download libtorch
46+
RUN wget -q https://download.pytorch.org/libtorch/cu111/libtorch-cxx11-abi-shared-with-deps-1.9.1%2Bcu111.zip \
47+
&& unzip libtorch-cxx11-abi-shared-with-deps-1.9.1+cu111.zip \
48+
&& mkdir libs \
49+
&& mv libtorch libs/libtorch \
50+
&& rm libtorch-cxx11-abi-shared-with-deps-1.9.1+cu111.zip
51+
52+
# Install cmake 3.21.0 version.
53+
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.21.0/cmake-3.21.0-linux-x86_64.tar.gz \
54+
&& tar -xzvf cmake-3.21.0-linux-x86_64.tar.gz \
55+
&& sudo ln -s /home/user/cmake-3.21.0-linux-x86_64/bin/cmake /usr/bin/cmake \
56+
&& sudo ln -s /home/user/root/cmake-3.21.0-linux-x86_64/bin/ctest /usr/bin/ctest \
57+
&& sudo ln -s /home/user/root/cmake-3.21.0-linux-x86_64/bin/cpack /usr/bin/cpack \
58+
&& rm cmake-3.21.0-linux-x86_64.tar.gz
59+
60+
# Terminal environment
61+
RUN git clone https://github.com/JeiKeiLim/my_term.git \
62+
&& cd my_term \
63+
&& ./run.sh
64+
65+
# Fix error messages with vim plugins
66+
RUN cd /home/user/.vim_runtime/sources_non_forked && rm -rf tlib vim-fugitive && git clone https://github.com/tomtom/tlib_vim.git tlib && git clone https://github.com/tpope/vim-fugitive.git
67+
68+
# Install vim 8.2 with YCM
69+
RUN sudo apt-get install -y software-properties-common \
70+
&& sudo add-apt-repository ppa:jonathonf/vim \
71+
&& sudo add-apt-repository ppa:ubuntu-toolchain-r/test \
72+
&& sudo apt-get update \
73+
&& sudo apt-get install -y vim g++-8 libstdc++6
74+
75+
RUN cd /home/user/.vim_runtime/my_plugins \
76+
&& git clone --recursive https://github.com/ycm-core/YouCompleteMe.git \
77+
&& cd YouCompleteMe \
78+
&& CC=gcc-8 CXX=g++-8 python3 install.py --clangd-completer
79+
80+
# Install DALI
81+
RUN python3 -m pip install --extra-index-url https://developer.download.nvidia.com/compute/redist nvidia-dali-cuda110
82+
83+
# Add PATH
84+
RUN echo "export PATH=/home/user/.local/bin:\$PATH" >> /home/user/.bashrc
85+
RUN echo "export LC_ALL=C.UTF-8 && export LANG=C.UTF-8" >> /home/user/.bashrc

__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Initialize module.
2+
3+
- Author: Haneol Kim
4+
5+
"""

config/config_validator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def __init__(self, config: Dict[str, Any], log: bool = True) -> None:
2929
@abstractmethod
3030
def check(self) -> None:
3131
"""Check configs are specified correctly."""
32-
3332
raise NotImplementedError
3433

3534
def check_key_exists(self) -> None:

config/train/cifar100/densenet_201.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -*- coding: utf-8 -*-
2+
"""Configurations for training densenet_small.
3+
4+
- Author: Curt-Park
5+
6+
"""
7+
8+
import os
9+
10+
config = {
11+
"SEED": 777,
12+
"AUG_TRAIN": "randaugment_train_cifar100_224",
13+
"AUG_TRAIN_PARAMS": dict(n_select=2, level=None),
14+
"AUG_TEST": "simple_augment_test_cifar100_224",
15+
"CUTMIX": dict(beta=1, prob=0.5),
16+
"DATASET": "CIFAR100",
17+
"MODEL_NAME": "densenet",
18+
"MODEL_PARAMS": dict(
19+
num_classes=100,
20+
inplanes=24,
21+
growthRate=32,
22+
compressionRate=2,
23+
block_configs=(6, 12, 48, 32),
24+
small_input=False,
25+
efficient=False,
26+
),
27+
"CRITERION": "CrossEntropy",
28+
"CRITERION_PARAMS": dict(num_classes=100, label_smoothing=0.1),
29+
"LR_SCHEDULER": "WarmupCosineLR",
30+
"LR_SCHEDULER_PARAMS": dict(
31+
warmup_epochs=5, start_lr=1e-3, min_lr=1e-5, n_rewinding=1
32+
),
33+
"BATCH_SIZE": 128,
34+
"LR": 0.1,
35+
"MOMENTUM": 0.9,
36+
"WEIGHT_DECAY": 1e-4,
37+
"NESTEROV": True,
38+
"EPOCHS": 300,
39+
"N_WORKERS": os.cpu_count(),
40+
}

environment.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,27 @@ dependencies:
77
- python=3.7
88
- progressbar2=3.53.1
99
- isort=5.1.4
10-
- black=19.10b0
11-
- mypy=0.770
12-
- flake8=3.8.2
10+
- black=22.3.0
11+
- flake8=3.8.3
1312
- flake8-bugbear=20.1.4
1413
- flake8-docstrings=1.5.0
1514
- pylint=2.6.0
1615
- pytest=6.1.1
1716
- pytest-pylint=0.17.0
1817
- pytest-flake8=1.0.6
1918
- pytest-mypy=0.7.0
20-
- pytorch=1.5.1
21-
- torchvision=0.6.1
19+
- flake8-polyfill=1.0.2
20+
- pytorch=1.9.1
21+
- torchvision=0.10.1
2222
- pip:
2323
- gdown==3.11.1
2424
- wandb
2525
- pyyaml
26+
- opencv-python==4.5.3.56
27+
- tensorly==0.6.0
28+
- p-tqdm==1.3.3
29+
- pyflakes==2.2.0
30+
- coverage==5.3
31+
- pytest-cov==2.10.1
32+
- mypy==0.971
33+
- flake8-annotations==2.4.0

0 commit comments

Comments
 (0)