repo์ถ”๊ฐ€ ํ›„, ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋‚  ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค.

์˜ค๋ฅ˜:4 https://packages.microsoft.com/repos/code stable Release                               
  Certificate verification failed: The certificate is NOT trusted. The certificate chain uses insecure algorithm.  
  Could not handshake: Error in the certificate verification. [IP: 23.99.120.248 443]
  
  : The repository 'https://packages.microsoft.com/repos/code stable Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.

์ด๋Š”, repo์˜ gpgํ‚ค๊ฐ€ ์ž˜ ๋ชป ๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ๋„ ์žˆ์ง€๋งŒ, ๋ณดํ†ต์€ ๊ฒฝ์œ ๊ตฌ๊ฐ„์— https๋ฐฉํ™”๋ฒฝ์ธ ๊ฒฝ์šฐ๊ฐ€ ๋งŽ๋‹ค.

์ด๋Ÿด ๊ฒฝ์šฐ์—๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด repo safety์ฒดํฌ๋ฅผ ๋ฌด๋ ฅํ™” ํ•ด ์ค€๋‹ค.

๋‹ค๋งŒ, ๋ณด์•ˆ ์ˆ˜์ค€์€ ๋‚ฎ์•„์ง€๋‹ˆ ์ฃผ์˜ํ•ด์•ผ ํ•œ๋‹ค.

$ sudo vi /etc/apt/apt.conf.d/50apt-file.conf

# ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰์— ์•„๋ž˜ ํ–‰์„ ์ถ”๊ฐ€ํ•œ๋‹ค.

Acquire { https::Verify-Peer false }

์ €์žฅ ํ›„ ์—…๋ฐ์ดํŠธ ํ•œ๋‹ค.

 

$ sudo apt update

Release.zip
0.43MB

install_docker

#!/bin/bash
# add the GPG key for the official Docker repository to the system
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# add the Docker repository to APT sources
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

# update the package database with the Docker packages from the newly added repo
sudo apt-get update

# install from the Docker repo instead of the default Ubuntu 16.04 repo
apt-cache policy docker-ce

# install docker
sudo apt-get install -y docker-ce

# check if the docker daemon is running
sudo systemctl status docker

# add user to docker group
sudo usermod -aG docker ${USER}
su - ${USER}
id -nG

install_nvidia_docker

# Install nvidia-runtime
# Download nvidia-runtime packages
curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
  sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-container-runtime/ubuntu16.04/amd64/nvidia-container-runtime.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt-get update

# Install nvidia-runtime
sudo apt-get install nvidia-container-runtime

# Docker Engine setup
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo tee /etc/systemd/system/docker.service.d/override.conf <<EOF
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd --host=fd:// --add-runtime=nvidia=/usr/bin/nvidia-container-runtime
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

# Daemon configuration file
sudo tee /etc/docker/daemon.json <<EOF
{
    "runtimes": {
        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}
EOF
sudo pkill -SIGHUP dockerd

# Command line
sudo dockerd --add-runtime=nvidia=/usr/bin/nvidia-container-runtime [...]

# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker
sudo pkill -SIGHUP dockerd

# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi

uninstall_docker

sudo rm -rf /var/run/docker/
sudo rm -rf /etc/docker/
sudo apt-get purge -y docker-engine docker docker.io docker-ce

Sequential API๋ฅผ ์ด์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

model = tf.keras.Sequential([

tf.keras.layers.Conv2D(32, 3, activation=relu,

                                               kernel_regualrizer=tf.keras.regularizers.l2(0.04),

                                               input_shape=(28, 28, 1)),

tf.keras.layers.MaxPooling2D(),

tf.keras.layers.Flatten(),

tf.keras.layers.Dropout(0.2),

tf.keras.layers.Dense(64, activation='relu'),

tf.keras.layers.BatchNormalization(),

tf.keras.layers.Dense(10, activation='softmax') ])

 

Functional API๋ฅผ ์ด์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

input = keras.Input(shape=(28, 28, 1), name='img')

x = layers.Conv2D(16, 3, activation='relu')(input)

x = layers.Conv2D(32, 3, activation='relu')(x)

x = layers.MaxPooling2D(3)(x)

x = layers.Conv2D(32, 3, activation='relu')(x)

x = layers.Conv2D(16, 3, activation='relu')(x)

output = layers.GlobalMaxPooling2D()(x)

encoder = keras.Model(input, output, name='encoder')

Model Subclassing์„ ์ด์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

class ResNet(tf.keras.Model):

    def __init__(self):

        super(ResNet, self).__init__()

        self.block_1 = ResNetBlock()

        self.block_2 = ResNetBlock()

        self.global_pool = layers.GlobalAveragePooling2D()

        self.classifier = Dense(num_classes)

    def call(self, inputs):

        x = self.block_1(input)

        x = self.block_2(x)

        x = self.global_pool(x)

        return self.classifier(x)

Layer List๋ฅผ ์ด์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

layer_list = [layer1, layer2, ..., layern]

new_model = tf.keras.Sequential(layer_list)

## ๋˜๋Š”

new_model = tf.kears.Sequential(layers=layer_list)

+ Recent posts