Commit 41d4d0b9 authored by insun park's avatar insun park
Browse files

docker/README.md 및 docker 하위 프로젝트 일괄 추가

parent c384e1fe
-----BEGIN CERTIFICATE-----
MIIEszCCA5ugAwIBAgIQCyWUIs7ZgSoVoE6ZUooO+jANBgkqhkiG9w0BAQsFADBh
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH
MjAeFw0xNzExMDIxMjI0MzNaFw0yNzExMDIxMjI0MzNaMGAxCzAJBgNVBAYTAlVT
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
b20xHzAdBgNVBAMTFlJhcGlkU1NMIFRMUyBSU0EgQ0EgRzEwggEiMA0GCSqGSIb3
DQEBAQUAA4IBDwAwggEKAoIBAQC/uVklRBI1FuJdUEkFCuDL/I3aJQiaZ6aibRHj
ap/ap9zy1aYNrphe7YcaNwMoPsZvXDR+hNJOo9gbgOYVTPq8gXc84I75YKOHiVA4
NrJJQZ6p2sJQyqx60HkEIjzIN+1LQLfXTlpuznToOa1hyTD0yyitFyOYwURM+/CI
8FNFMpBhw22hpeAQkOOLmsqT5QZJYeik7qlvn8gfD+XdDnk3kkuuu0eG+vuyrSGr
5uX5LRhFWlv1zFQDch/EKmd163m6z/ycx/qLa9zyvILc7cQpb+k7TLra9WE17YPS
n9ANjG+ECo9PDW3N9lwhKQCNvw1gGoguyCQu7HE7BnW8eSSFAgMBAAGjggFmMIIB
YjAdBgNVHQ4EFgQUDNtsgkkPSmcKuBTuesRIUojrVjgwHwYDVR0jBBgwFoAUTiJU
IBiV5uNu5g/6+rkS7QYXjzkwDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsG
AQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEAMDQGCCsGAQUFB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nI/y
uum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F
8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQvIOlCsRn
KPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAPBgNVHRMB
Af8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu5g/6
+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWL
Sn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+m
QrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/Dz
MNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ918rGOmaFv
E7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTepLiaWN0b
fVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTflMrahADEA
-----END PKCS7-----
#!/bin/bash
# SSH
/usr/sbin/sshd -D & sleep 5
# MariaDB 시작 (DB 실행 후 루트 원격 계정 생성을 위해 sleep)
service mysql start && sleep 5
# 루트 원격 계정 생성
mysql -u root -pfnxmdkagh < ./setting.sql && sleep 5
# Tomcat 시작
/usr/local/tomcat/bin/catalina.sh run && sleep 5
# Service 재시작 시 Docker가 종료되지 않도록 대기
tail -f /dev/null
FROM ubuntu:20.04
# 패키지 설치 및 ssh 설치&설정
RUN apt-get update && apt-get -y upgrade && \
apt-get install -y openssh-server && \
apt-get install -y mariadb-server && \
apt-get install -y mariadb-client && \
apt-get install -y vim && \
apt-get install -y wget && \
apt-get install -y curl && \
apt-get install -y iputils-ping && \
apt-get install -y openjdk-8-jdk && \
apt-get install -y gnupg2 && \
apt-get install -y gnupg && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# 사용자 홈 디렉토리 설정
RUN useradd -ms /bin/bash jenkins
RUN chown -R jenkins:jenkins /home/jenkins
# Set up configuration for SSH
RUN mkdir /var/run/sshd && \
echo 'root:!@#gds$%^' | chpasswd && \
sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config && \
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config
# SSH login fix. Otherwise, user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
# Jenkins 설치
RUN curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
RUN echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
RUN apt update && apt upgrade -y
RUN apt-get install -y jenkins
# Jenkins 설정 파일 복사
COPY jenkins_config.xml /var/jenkins_home/config.xml
# 로그 파일 경로 설정
ENV JENKINS_LOG_DIR /var/log/jenkins
RUN mkdir -p $JENKINS_LOG_DIR
# java and tomcat path
RUN echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" >> /etc/profile && \
echo "export CATALINA_HOME=/usr/local/tomcat" >> /etc/profile && \
echo "export CLASSPATH=.:$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/lib/jsp-api.jar:$CATALINA_HOME/lib/servlet-api.jar" >> /etc/profile && \
echo "export LANG=ko_KR.UTF-8" >> /etc/profile
# 포트 노출
EXPOSE 22 8080 50000
# start service
RUN mkdir service
COPY start_service.sh /service
RUN chmod +x /service/start_service.sh
CMD ["/service/start_service.sh"]
# Jenkins CI/CD 서버
이 프로젝트는 Docker를 사용하여 Jenkins CI/CD 자동화 서버를 구축하기 위한 환경입니다. Ubuntu 20.04 위에 OpenJDK 8과 Jenkins가 설치되며, 데이터는 호스트의 로컬 디렉토리에 영속적으로 저장됩니다.
## 주요 기능
- **기반 환경**: Ubuntu 20.04, OpenJDK 8
- **CI/CD 서버**: Jenkins (공식 저장소에서 설치)
- **데이터베이스**: MariaDB Server/Client 포함 (Jenkins 작업에서 필요시 사용 가능)
- **원격 접속**: OpenSSH Server
- **데이터 영속성**: Jenkins의 모든 설정, 작업 내역, 로그가 호스트의 `jenkins_data`, `jenkins_log` 디렉토리에 바인드 마운트되어 보존됩니다.
## 사전 요구사항
- [Docker](https://www.docker.com/get-started)
- [Docker Compose](https://docs.docker.com/compose/install/)
## 사용 방법
### 1. 서비스 시작 및 빌드
아래 스크립트를 실행하여 Docker 이미지를 빌드하고 Jenkins 컨테이너를 시작합니다.
```bash
./rebuild.sh
```
스크립트를 실행하면 현재 디렉토리에 `jenkins_data``jenkins_log` 폴더가 자동으로 생성되며, 컨테이너의 데이터 및 로그와 동기화됩니다.
### 2. 초기 관리자 비밀번호 확인
Jenkins가 처음 실행되면 초기 관리자 비밀번호가 생성됩니다. 이 비밀번호는 웹 UI에 처음 접속할 때 필요합니다. 아래 명령어로 확인할 수 있습니다.
```bash
# 컨테이너가 완전히 실행된 후 잠시 기다렸다가 실행
docker exec -it jenkins-jenkins-1 cat /var/jenkins_home/secrets/initialAdminPassword
```
*참고: `jenkins-jenkins-1`은 `docker ps`로 확인한 실제 컨테이너 이름으로 변경해야 할 수 있습니다.*
### 3. Jenkins 초기 설정
1. 웹 브라우저에서 `http://<서버_IP>:8087` 주소로 접속합니다.
2. 위 단계에서 확인한 **Administrator password**를 입력합니다.
3. 'Install suggested plugins'를 선택하여 추천 플러그인을 설치하고, 관리자 계정을 생성하여 설정을 완료합니다.
## 서비스 접속 정보
| 서비스 | 호스트 포트 | 컨테이너 포트 | 주소 / 설명 |
|---|---|---|---|
| Jenkins Web UI | `8087` | `8080` | `http://<서버_IP>:8087` |
| Jenkins Agent | `50000` | `50000` | Jenkins 에이전트 연결 포트 |
| SSH | `2116` | `22` | `ssh root@<서버_IP> -p 2116` (root/!@#gds$%^) |
\ No newline at end of file
version: '3'
services:
jenkins:
build:
context: .
dockerfile: Dockerfile
ports:
- "2116:22"
- "8087:8080"
- "50000:50000"
network_mode: bridge
volumes:
- ./jenkins_data:/var/jenkins_home
- ./jenkins_log:/var/log/jenkins
<jenkins>
<security>
<authorizationStrategy class="hudson.security.FullControlOnceLoggedInAuthorizationStrategy">
<denyAnonymousReadAccess>false</denyAnonymousReadAccess>
</authorizationStrategy>
</security>
</jenkins>
#!/bin/bash
docker build -t jenkins .
docker-compose up -d --build
#!/bin/bash
service ssh start && sleep 5
service jenkins start
# 베이스 이미지로부터 시작합니다.
FROM ubuntu:22.04
# 필수 패키지 설치
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y openssh-server gcc mecab libmecab-dev mecab-ipadic-utf8 vim g++ wget curl net-tools ubuntu-drivers-common git python3.10 python3-pip python3.10-venv && \
pip install eunjeon
# Set up configuration for SSH
RUN mkdir /var/run/sshd && \
echo 'root:!@#gds$%^' | chpasswd && \
sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
# 작업 디렉토리 설정
WORKDIR /app
# 가상 환경 생성
RUN python3.10 -m venv /app/venv
# 가상 환경 활성화 및 requirements.txt 설치
COPY requirements.txt .
RUN /app/venv/bin/pip install --upgrade pip && \
/app/venv/bin/pip install mkl-fft && \
/app/venv/bin/pip install -r requirements.txt
# Jupyter 및 추가 패키지 설치
RUN /app/venv/bin/pip install jupyter notebook theme-darcula torch torchvision torchaudio
# Jupyter의 설정 파일을 생성합니다.
RUN /app/venv/bin/jupyter notebook --generate-config
# 권한 설정
COPY start_service.sh .
RUN chmod +x /app/start_service.sh
# Jupyter의 비밀번호를 설정합니다.
RUN echo "c.NotebookApp.password = 'sha1:3c2088751e24:247c5332fcc1f9bb71203adb8573a701abe0f3a9'" >> /root/.jupyter/jupyter_notebook_config.py
# 디렉토리 권한 설정
RUN chown -R root:root /app && chmod -R 755 /app
# 포트 설정
EXPOSE 22 8888
# 가상 환경 활성화 후 Jupyter 및 SSH 서버 실행
CMD ["/bin/sh", "-c", "/app/venv/bin/jupyter lab --ip=0.0.0.0 --port=8888 --allow-root --no-browser && /app/start_service.sh"]
# Jupyter Lab Docker 환경
이 프로젝트는 GPU를 지원하는 Jupyter Lab 실행 환경을 Docker를 사용하여 구축합니다. 사전 구성된 Python 3.10 환경, SSH 접속, 영구적인 노트북 저장 공간을 제공합니다.
## 주요 기능
- **베이스 이미지**: Ubuntu 22.04
- **Python 버전**: Python 3.10 (venv 가상 환경)
- **주요 라이브러리**:
- Jupyter Lab
- PyTorch (NVIDIA GPU 지원)
- `requirements.txt`에 명시된 기타 라이브러리
- **서비스**:
- Jupyter Lab 웹 인터페이스
- SSH 서버 접속
## 사전 요구사항
- [Docker](https://www.docker.com/get-started)
- [Docker Compose](https://docs.docker.com/compose/install/)
- (GPU 사용 시) [NVIDIA Docker Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
## 사용 방법
### 1. 서비스 시작
아래 명령어를 실행하여 Docker 컨테이너를 빌드하고 백그라운드에서 실행합니다.
```bash
docker-compose up -d
```
### 2. 이미지 재빌드
`Dockerfile`이나 환경에 변경 사항이 있을 경우, 아래 스크립트를 실행하여 이미지를 다시 빌드하고 서비스를 시작할 수 있습니다.
```bash
./rebuild.sh
```
## 서비스 접속 정보
### Jupyter Lab
- **URL**: `http://<서버_IP>:8888`
- **비밀번호**: `123`
### SSH
- **명령어**: `ssh root@<서버_IP> -p 2115`
- **비밀번호**: `!@#gds$%^`
## 파일 및 디렉토리 설명
- `Dockerfile`: Docker 이미지를 빌드하기 위한 설정 파일입니다. OS, 시스템 패키지, Python 라이브러리 등이 정의되어 있습니다.
- `docker-compose.yml`: Docker 서비스를 관리하기 위한 파일입니다. 포트 매핑, 볼륨 마운트, GPU 할당 등을 설정합니다.
- `requirements.txt`: Python 가상 환경에 설치될 패키지 목록입니다.
- `notebooks/`: Jupyter 노트북 파일이 저장되는 디렉토리입니다. 이 디렉토리는 컨테이너의 `/app/notebooks`와 마운트되어 데이터가 영구적으로 보존됩니다.
- `rebuild.sh`: 이미지를 다시 빌드하고 컨테이너를 재시작하는 스크립트입니다.
- `start_service.sh`: 컨테이너 내부에서 SSH 서비스를 시작하는 스크립트입니다.
\ No newline at end of file
version: '3'
services:
server:
build:
context: .
dockerfile: Dockerfile
ports:
- "2115:22"
- "8888:8888"
restart: always
volumes:
- ./notebooks:/app/notebooks
deploy:
resources:
reservations:
devices:
- driver: nvidia
capabilities: ["gpu"]
count: 1 # Adjust count for the number of GPUs you want to use
environment:
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "ede03008-a35d-4d65-8a64-ddf4bc5c4d41",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python3.10/dist-packages/urllib3/connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'www.cleaneye.go.kr'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"['siteHome', 'skipNavi', 'sitemapDivBG', 'sitemapDiv', 'sitemapWrap', 'sitemap', 'target_01', 'target_02', 'target_03', 'target_04', 'target_05', 'target_06', 'closeSitemap', 'mobileNavWrap', 'mSearch', 'mMenu', 'mLogo', 'headerDiv', 'topWrap', 'logo', 'mainNav', 'mainGNB', 'topSearch', 'totalSearchFormAction', 'skyBannerWarp', 'skyBannerLastElement', 'topWrapBg', 'topMenu', 'topSubMenu', 'targetEntId', 'targetEntName', 'targetEntKind', 'inputEntId', 'inputItemNo', 'locationDiv', 'container', 'contents', 'printBtn', 'frameTop', 'ceBox', 'frameLeft', 'frameContents', 'footerDiv', 'footerNavWarp', 'fncTermsDicLi', 'emailRejectLi', 'copyrightPolicyLi', 'prvcPrcsMthd', 'footerCopyWarp', 'copyright', 'logoBtm', 'pcShowBtn', 'gongsiInfoPop', 'gongsiInfoPopBody', 'popContents']\n"
]
}
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"id": "6687628a-472e-495a-82c0-b1dacde99e56",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: pip in /usr/lib/python3/dist-packages (22.0.2)\n",
"Collecting pip\n",
" Using cached pip-24.2-py3-none-any.whl (1.8 MB)\n",
"Installing collected packages: pip\n",
" Attempting uninstall: pip\n",
" Found existing installation: pip 22.0.2\n",
" Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr\n",
" Can't uninstall 'pip'. No files were found to uninstall.\n",
"Successfully installed pip-24.2\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0mCollecting unsloth@ git+https://github.com/unslothai/unsloth.git (from unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Cloning https://github.com/unslothai/unsloth.git to /tmp/pip-install-42mbmn6k/unsloth_a3b84356d92343808c0187bf6996ed5b\n",
" Running command git clone --filter=blob:none --quiet https://github.com/unslothai/unsloth.git /tmp/pip-install-42mbmn6k/unsloth_a3b84356d92343808c0187bf6996ed5b\n",
" Resolved https://github.com/unslothai/unsloth.git to commit 976d11a10d54383aeb7a692c69e01151a20bfd72\n",
" Installing build dependencies ... \u001b[?25ldone\n",
"\u001b[?25h Getting requirements to build wheel ... \u001b[?25ldone\n",
"\u001b[?25h Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n",
"\u001b[?25hRequirement already satisfied: bitsandbytes>=0.43.3 in /usr/local/lib/python3.10/dist-packages (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (0.43.3)\n",
"Collecting torch (from bitsandbytes>=0.43.3->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Using cached torch-2.4.0-cp310-cp310-manylinux1_x86_64.whl.metadata (26 kB)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from bitsandbytes>=0.43.3->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (2.0.1)\n",
"Collecting xformers@ https://download.pytorch.org/whl/cu121/xformers-0.0.27.post2-cp310-cp310-manylinux2014_x86_64.whl (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Downloading https://download.pytorch.org/whl/cu121/xformers-0.0.27.post2-cp310-cp310-manylinux2014_x86_64.whl (20.8 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m20.8/20.8 MB\u001b[0m \u001b[31m49.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (24.1)\n",
"Collecting tyro (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Downloading tyro-0.8.10-py3-none-any.whl.metadata (8.4 kB)\n",
"Collecting transformers>=4.43.2 (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Downloading transformers-4.44.2-py3-none-any.whl.metadata (43 kB)\n",
"Requirement already satisfied: datasets>=2.16.0 in /usr/local/lib/python3.10/dist-packages (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (2.20.0)\n",
"Collecting sentencepiece>=0.2.0 (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Downloading sentencepiece-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (7.7 kB)\n",
"Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (4.66.5)\n",
"Collecting psutil (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Downloading psutil-6.0.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (21 kB)\n",
"Collecting wheel>=0.42.0 (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Using cached wheel-0.44.0-py3-none-any.whl.metadata (2.3 kB)\n",
"Requirement already satisfied: accelerate>=0.26.1 in /usr/local/lib/python3.10/dist-packages (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (0.33.0)\n",
"Requirement already satisfied: trl!=0.9.0,!=0.9.1,!=0.9.2,!=0.9.3,>=0.7.9 in /usr/local/lib/python3.10/dist-packages (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (0.8.6)\n",
"Requirement already satisfied: peft!=0.11.0,>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (0.12.0)\n",
"Collecting protobuf<4.0.0 (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Downloading protobuf-3.20.3-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.metadata (679 bytes)\n",
"Requirement already satisfied: huggingface-hub in /usr/local/lib/python3.10/dist-packages (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (0.24.5)\n",
"Collecting hf-transfer (from unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Downloading hf_transfer-0.1.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.7 kB)\n",
"Collecting numpy (from bitsandbytes>=0.43.3->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Using cached numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)\n",
"Requirement already satisfied: pyyaml in /usr/local/lib/python3.10/dist-packages (from accelerate>=0.26.1->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (6.0.2)\n",
"Collecting safetensors>=0.3.1 (from accelerate>=0.26.1->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Downloading safetensors-0.4.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.8 kB)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from datasets>=2.16.0->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (3.15.4)\n",
"Requirement already satisfied: pyarrow>=15.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets>=2.16.0->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (17.0.0)\n",
"Requirement already satisfied: pyarrow-hotfix in /usr/local/lib/python3.10/dist-packages (from datasets>=2.16.0->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (0.6)\n",
"Requirement already satisfied: dill<0.3.9,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from datasets>=2.16.0->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (0.3.8)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from datasets>=2.16.0->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (2.2.2)\n",
"Requirement already satisfied: requests>=2.32.2 in /usr/local/lib/python3.10/dist-packages (from datasets>=2.16.0->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (2.32.3)\n",
"Requirement already satisfied: xxhash in /usr/local/lib/python3.10/dist-packages (from datasets>=2.16.0->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (3.4.1)\n",
"Requirement already satisfied: multiprocess in /usr/local/lib/python3.10/dist-packages (from datasets>=2.16.0->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (0.70.16)\n",
"Requirement already satisfied: fsspec<=2024.5.0,>=2023.1.0 in /usr/local/lib/python3.10/dist-packages (from fsspec[http]<=2024.5.0,>=2023.1.0->datasets>=2.16.0->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (2024.5.0)\n",
"Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from datasets>=2.16.0->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (3.10.3)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git) (4.12.2)\n",
"Collecting sympy (from torch->bitsandbytes>=0.43.3->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Using cached sympy-1.13.2-py3-none-any.whl.metadata (12 kB)\n",
"Collecting networkx (from torch->bitsandbytes>=0.43.3->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[cu121-torch240]@ git+https://github.com/unslothai/unsloth.git)\n",
" Using cached networkx-3.3-py3-none-any.whl.metadata (5.1 kB)\n",
[Trash Info]
Path=Untitled.ipynb
DeletionDate=2024-10-28T07:05:46
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment