Skip to main content

安装

pip install tsc-auto

功能1: ta

介绍

  • 可以自动检测 torch 和 tensorflow 版本, 并自动设置环境变量相应的 cuda, 同时自动选择占用显存最低的显卡运行.
  • 可以实现自动后台运行运行并记录和查看日志/中止程序.
  • 需要在 anaconda 环境下使用.
  • 在程序终止时可以自动发送微信通知.

使用方式

  • 查看帮助: ta --help
  • 自动选择最低显存占用显卡跑 torch 的 cnn.py 程序: ta -p -a cnn.py
  • 手动选择编号0和1的显卡跑 tensorflow 的 cnn.py 程序: ta -t -d 0,1 -a cnn.py
  • 发送通知步骤(借助 pushplus 实现)
    1. 微信登录: https://pushplus.plus/login.html
    2. 激活微信公众号, 接收文章推送, 关闭消息免打扰
    3. 获取token: https://pushplus.plus/push1.html
    4. 测试: ta -x 你的token -o echo 成功
    5. 注意: 运行机需要联网; 不能使用ta自带的后台运行方式(可以手动nohup); 频率太高可能封号/封ip
  • ta --benchmark 可测试显卡性能
  • ta --wait -c=0.1 -m=0.8 -t=10 -g=1,2 python test.py 可等待显卡1,2满足空闲条件(至少剩余10%gpu使用率+至少剩余80%显存+持续10秒钟)后再执行后面的命令
  • ta --showp 可显示当前用户的所有运行程序(去重复)命令
  • ta --show=120 显示当前系统资源信息,120代表显示一行最大长度

cuda的位置默认在用户主目录 (可以使用 ln -s 软链接)

  • ...
  • ~/cuda/8.0
  • ...
  • ~/cuda/11.3
  • ...

下载处理好的cuda

如果自行安装 cuda 和 cudnn, 需要处理的方式

  • cd ~/cuda
  • mv /usr/local/cuda-11.0/ 11.0
  • cp cudnn-v8.2.0.53/include/cudnn.h 11.0/include/
  • cp cudnn-v8.2.0.53/lib64/libcudnn* 11.0/lib64
  • chmod a+r 11.0/include/cudnn.h 11.0/lib64/libcudnn*

功能2: tkill

介绍

  • 用于限制linux系统的cpu/gpu资源使用, 例如可以针对以下内容进行限制:
{
    's': 10,  # 多少秒检测一次
    'cpu_core_u': 2147483647,  # 一个用户-最多CPU占用(百分比,如100表示占满1个超线程)
    'gpu_card_u': 2,  # 一个用户-最多显卡(张)
    'gpu_mem_u': 24,  # 一个用户-最大显存(GB)
    'gpu_card': 2,  # 单进程-最多显卡(张)
    'gpu_mem': 21000,  # 单进程-最大显存(MB)
    'gpu_day': 15,  # 单进程-最长显卡占用时间(天)
    'cpu_day': 15,  # 单进程-最长cpu占用时间(天)
    'cpu_day_core_limit': 80,  # CPU占用百分比超过此值的进程才会使 cpu_day 配置生效
    'ignore_u': {'999',},  # 忽略的用户, 默认会包含 /etc/passwd 中路径不含有 /home/ 的用户
    'include_u': {'example_user',},  # 不可忽略的用户, 优先级高于 ignore_u
    # 针对每个特殊配置设置用户,没写的默认使用上述设置,越靠list后面的优先级越高会覆盖前面一样的用户配置
    'conf': [
        {  # 一组配置和对应的用户
            'gpu_mem': 24000,
            'conf_u': {'tsc'},  # 使用这组配置的用户
        },
    ],
    # 针对每个用户的额外配置, 没写的默认使用上述设置, 优先级最高
    'user': {
        'example_user': {
            'gpu_mem_u': 41,
            'gpu_card_u': 3,
        },
    },
}
  • 退出某用户在显卡中的进程, 防止程序结束而显存没有释放: tkill --knp username

使用方式

  • 查看帮助: tkill -h
  • 首先, 运行 tkill -c 'kill.config' -t 再终止程序(ctrl+c), 用于生成默认配置文件
  • 然后, 修改配置文件的内容
  • 最后, 运行 tkill -c 'kill.config' 开启限制程序

功能3: ressh

介绍

  • 用于在断网后自动重新连接ssh,也可以在一行命令行中直接输入密码登录

使用方式

  • 查看帮助: ressh -h
  • 登录: ressh user@ip -p port
  • 登录后自动输入密码并自动进入tmux: ressh user@ip -p port --tmux --password=你的密码
  • 登录后自动进入指定名称的tmux会话, 不存在则新建: ressh user@ip -p port --tmu ressh

功能4: tp

介绍

  • 服务器代理

使用方式

  • 服务器和客户端都需要安装包: pip install tsc-auto
  • 本地打开http代理开放到端口 7890, 可借助 clash
  • 登录服务器: ressh ssh参数 --tp
  • 登录后使用代理: tp curl google.com

Metadata

Release files for tsc-auto 0.54

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tsc-auto 0.54
File Size Uploaded
tsc_auto-0.54.tar.gz 94.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tsc-auto 0.54
File Interpreter ABI Platform
tsc_auto-0.54-py3-none-any.whl Python 3 none any Details

Total release size: 189.4 kB

Release files / tsc_auto-0.54.tar.gz

Download URL tsc_auto-0.54.tar.gz
Size 94.1 kB
Tags Source
SHA-256 checksum
How to use checksums
dd5408c0d509d64b7cee45fe2c0bf148798ab213fd1bc431fea159daa17709e5
BLAKE2b-256 checksum
How to use checksums
aa16ec27119576c26b82f171f7baaac5c9fa780ffd8a124ef3315f013d5c6799
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / tsc_auto-0.54-py3-none-any.whl

Download URL tsc_auto-0.54-py3-none-any.whl
Size 95.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d03a6a1ccff517950f5b8513605b6c60cf4371fbb0a039339cedfa447339d3bc
BLAKE2b-256 checksum
How to use checksums
3e12b66925bb97b2d7caf0e2dd33ab65f877a877fd79488d2dcf3628426b48c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.54 This release

2 release files

0.53

1 release file

0.52

1 release file

0.51

1 release file

0.50

1 release file

0.49

1 release file

0.48

1 release file

0.47

1 release file

0.46

1 release file

0.45

1 release file

0.44

1 release file

0.43

1 release file

0.42

1 release file

0.41

1 release file

0.40

1 release file

0.39

1 release file

0.38

1 release file

0.37

1 release file

0.36

1 release file

0.35

1 release file

0.34

1 release file

0.33

1 release file

0.32

1 release file

0.31

1 release file

0.30

1 release file

0.29

1 release file

0.28

1 release file

0.27

1 release file

0.26

1 release file

0.25

1 release file

0.24

1 release file

0.23

1 release file

0.22

1 release file

0.21

1 release file

0.20

1 release file

0.19

1 release file

0.18

1 release file

0.17

1 release file

0.16

1 release file

0.15

1 release file

0.14

1 release file

0.13

1 release file

0.12

1 release file

0.11

1 release file

0.10

1 release file

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page