这些 Docker 命令有什么特别的原因不在分离模式下运行(缺少 -d)吗?
如果你是指“我难道不应该用 -d 来启动它们吗?” 答案很可能是肯定的。
如果你真正想问的是“为什么 OP 没有告诉我用 -d 来启动这些命令?”,我认为它们只是作为如何启动并使其正常工作的示例。在实际应用中,你可能需要做一些 \u003cother stuff\u003e 来以一种在生产环境中有效的方式启动它们。
这正是我要问的问题,你一语中的。我配置我的 Docker 实例已经有一段时间了,现在又想起来了。当你提到我应该做“其他事情”才能让它们适用于生产环境时,有没有什么其他事情应该让我大声疾呼“必须这样做!”(除了显而易见地更改每个 Docker 实例中相同的端口号 6666 之外)?
好的。那么对于管道分隔的 API 密钥,它们与服务主机是完全任意的吗?我们是否只需指定我们希望从客户端接受的任何字母数字密钥?
更改端口号比让它在后台运行有什么“不显而易见”的呢?
这就是问题所在。如果你不清楚你认为显而易见的东西,就无法回答这个问题。大多数情况下,如果你不能确定自己知道如何让这些东西变得有用,那么你可能需要在这里得不到的帮助。 ![]()
因为我过去运行过几十个 Docker 容器。我只是在过去两年里没有接触过 Docker,然后深入研究了一下。一开始并不明显,因为我有一段时间没接触过了,但在讨论后,我对使用 Docker 的基本知识又回来了。
这就是问题所在。如果不深入了解你认为显而易见的东西,就无法回答这个问题。大多数情况下,如果你不确定如何让这些东西有用,那么你可能需要在这里得不到的帮助。
但这正是问题的关键。有时,即使是像我这样有不同 Docker 系统使用经验的人,显而易见的东西也不那么显而易见。有人可能会认为,你应该在提问之前就知道答案。请理解,我们中的一些人作为志愿者社区服务,并不花费 24/7 的时间来学习 Discourse 最细微的细节,直到 Postgres 数据结构等等。我觉得你是在否定我,这在应该是一个社区论坛,每个人都应该自由快乐地互相帮助的地方,是不受欢迎的。
言归正传,我做了一些谷歌搜索,试图确定 API_KEYS 应该如何使用,但没有找到。我明白我可能错过了显而易见的东西,这对于像你这样拥有丰富平台知识的 Discourse 专业人士来说可能令人沮丧,但我在这里试图进行社区讨论,以便其他技能水平不如你的用户也能受益。毕竟,其目的是让 Discourse 的开发者以外的人也能使用这个软件。
我明白你的感受。遇到我运行的某个服务,却几乎不记得我是怎么启动它的,这种情况比我希望的要频繁。
没错。即使是我们为自己写的说明,当我们再次需要它们时也可能看不懂。
抱歉。我无意冒犯或显得粗鲁,看起来我确实是这样做了。我的观点只是,支持那些运行标准安装的用户已经够难了,所以弄清楚你的技能是什么,你打算如何启动它,它是否会在开放的互联网上运行,以及你是否知道如何或想要用 https 来保护它(如果你认为用 API 密钥来保护它,你可能想要这样做),这些都很困难。
是的。如果你要把这个东西放在别人可以访问的地方,我认为你需要定义 API_KEYS 变量,并找到一种方法来生成一些随机的东西作为密钥。然后,你会在插件的设置中输入相同的密钥。我就是这么做的。我没有检查使用错误的密钥是否会导致它崩溃,说实话,我觉得我应该检查的。也许我会在我即将添加该插件的实例上这样做。
但如果 OP 包含 -d 并设置 API_KEYS 环境变量,可能会更好。
API_KEYS 环境变量是一个可选的设置,如果您因为任何原因想限制服务只允许提供配置的 API_KEYS 之一的客户端通过其标头进行访问,则可以使用它。
如果您在内部为单个实例运行它,则不需要这样做,但如果您在互联网上或在共享环境中运行它,则可能很有用。
这些服务可以被多个 Discourse 安装共用,还是应该为每个站点单独运行?
它们都可以安全地在实例之间共享。
仍然可以使用带有 OpenAI API 密钥的摘要功能吗?
是的,填写密钥并在摘要设置中选择一个OpenAI模型。
如果该主题使用的语言不是英语或次要语言,则存在一个小问题——它有时会使用正确的语言,然后突然开始使用英语。两种改变语言的方式似乎都是完全随机发生的。
我正在测试摘要端点:
docker run -d --rm --gpus all --shm-size 1g -p 80:80 -v /mnt:/data -e GPTQ_BITS=4 -e GPTQ_GROUPSIZE=32 -e REVISION=gptq-4bit-32g-actorder_True ghcr.io/huggingface/text-generation-inference:latest --model-id TheBloke/Upstage-Llama-2-70B-instruct-v2-GPTQ --max-batch-prefill-tokens=12000 --max-total-tokens=12000 --max-input-length=10000 --quantize=gptq --sharded=true --num-shard=$(lspci | grep NVIDIA | wc -l | tr -d '\\n') --rope-factor=2
但是,当我运行时,我收到以下错误。这台机器有 (2) 块 Tesla T4,没有其他进程正在访问 GPU。请参阅下面的使用情况。
user@gpu2-hc1node:~$ sudo docker logs -f 68e27eb51ee1
2023-12-14T21:30:12.861320Z INFO text_generation_launcher: Args { model_id: "TheBloke/Upstage-Llama-2-70B-instruct-v2-GPTQ", revision: Some("gptq-4bit-32g-actorder_True"), validation_workers: 2, sharded: Some(true), num_shard: Some(2), quantize: Some(Gptq), speculate: None, dtype: None, trust_remote_code: false, max_concurrent_requests: 128, max_best_of: 2, max_stop_sequences: 4, max_top_n_tokens: 5, max_input_length: 10000, max_total_tokens: 12000, waiting_served_ratio: 1.2, max_batch_prefill_tokens: 12000, max_batch_total_tokens: None, max_waiting_tokens: 20, hostname: "68e27eb51ee1", port: 80, shard_uds_path: "/tmp/text-generation-server", master_addr: "localhost", master_port: 29500, huggingface_hub_cache: Some("/data"), weights_cache_override: None, disable_custom_kernels: false, cuda_memory_fraction: 1.0, rope_scaling: None, rope_factor: Some(2.0), json_output: false, otlp_endpoint: None, cors_allow_origin: [], watermark_gamma: None, watermark_delta: None, ngrok: false, ngrok_authtoken: None, ngrok_edge: None, env: false }
2023-12-14T21:30:12.861350Z INFO text_generation_launcher: Sharding model on 2 processes
2023-12-14T21:30:12.861441Z INFO download: text_generation_launcher: Starting download process.
2023-12-14T21:30:19.986231Z INFO text_generation_launcher: Files are already present on the host. Skipping download.
2023-12-14T21:30:20.771527Z INFO download: text_generation_launcher: Successfully downloaded weights.
2023-12-14T21:30:20.771941Z INFO shard-manager: text_generation_launcher: Starting shard rank=1
2023-12-14T21:30:20.771967Z INFO shard-manager: text_generation_launcher: Starting shard rank=0
2023-12-14T21:30:27.769624Z WARN text_generation_launcher: Disabling exllama v2 and using v1 instead because there are issues when sharding
2023-12-14T21:30:27.997163Z WARN text_generation_launcher: Disabling exllama v2 and using v1 instead because there are issues when sharding
2023-12-14T21:30:28.046134Z WARN text_generation_launcher: Unable to use Flash Attention V2: GPU with CUDA capability 7 5 is not supported for Flash Attention V2
2023-12-14T21:30:28.071687Z WARN text_generation_launcher: Could not import Mistral model: Mistral model requires flash attn v2
2023-12-14T21:30:28.072298Z WARN text_generation_launcher: Could not import Mixtral model: Mistral model requires flash attn v2
2023-12-14T21:30:28.241375Z WARN text_generation_launcher: Unable to use Flash Attention V2: GPU with CUDA capability 7 5 is not supported for Flash Attention V2
2023-12-14T21:30:28.262756Z WARN text_generation_launcher: Could not import Mistral model: Mistral model requires flash attn v2
2023-12-14T21:30:28.263363Z WARN text_generation_launcher: Could not import Mixtral model: Mistral model requires flash attn v2
2023-12-14T21:30:30.786133Z INFO shard-manager: text_generation_launcher: Waiting for shard to be ready... rank=1
2023-12-14T21:30:30.786133Z INFO shard-manager: text_generation_launcher: Waiting for shard to be ready... rank=0
2023-12-14T21:30:40.348755Z ERROR text_generation_launcher: Error when initializing model
Traceback (most recent call last):
File "/opt/conda/lib/python3.10/site-packages/text_generation_server/utils/weights.py", line 191, in get_multi_weights_col
qweight = torch.cat(
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 112.00 MiB. GPU 0 has a total capacty of 14.76 GiB of which 74.75 MiB is free. Process 19973 has 14.68 GiB memory in use. Of the allocated memory 13.73 GiB is allocated by PyTorch, and 74.36 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
模型崩溃后运行 nvidia-smi。
Thu Dec 14 15:39:55 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.223.02 Driver Version: 470.223.02 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------|
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla T4 Off | 00000000:86:00.0 Off | 0 |
| N/A 54C P0 28W / 70W | 0MiB / 15109MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 1 Tesla T4 Off | 00000000:AF:00.0 Off | 0 |
| N/A 55C P0 28W / 70W | 0MiB / 15109MiB | 5% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
当我启动模型时,我可以看到两个 GPU 的使用率都增加到大约 100%,然后崩溃。
两个 T4 对于该模型来说太少了。您可以尝试使用兼容的 7B 模型。
我能够在 T4 上运行以下模式
sudo docker run --gpus all --shm-size 1g -p 80:80 -v /home/deeznnutz/discourse/data:/data ghcr.io/huggingface/text-generation-inference:1.3 --model-id tiiuae/falcon-7b-instruct --max-batch-prefill-tokens 2048
我可以在本地测试它,并且它有效:
curl https://Public_URL/generate -X POST -d '{\"inputs\":\"What is Deep Learning?\",\"parameters\":{\"max_new_tokens\":20}}' -H 'Content-Type: application/json'
{\"generated_text\":\"\\nDeep learning is a branch of machine learning that uses artificial neural networks to learn and make decisions.\"}
但是,当我尝试在 Discourse 中使用这些设置运行它时
ai summarization discourse service api endpoint: https://URL/generate/
ai summarization discourse service api key: random numbers
summarization strategy: Discourse AI's long-t5-tglobal....-book-summary
我收到以下错误。
Message (6 copies reported)
Job exception: Net::HTTPBadResponse
Backtrace
/var/www/discourse/plugins/discourse-ai/lib/inference/discourse_classifier.rb:13:in `perform!'
/var/www/discourse/plugins/discourse-ai/lib/summarization/strategies/truncate_content.rb:46:in `completion'
/var/www/discourse/plugins/discourse-ai/lib/summarization/strategies/truncate_content.rb:42:in `summarize_with_truncation'
/var/www/discourse/plugins/discourse-ai/lib/summarization/strategies/truncate_content.rb:23:in `summarize'
/var/www/discourse/app/services/topic_summarization.rb:38:in `summarize'
/var/www/discourse/app/jobs/regular/stream_topic_summary.rb:25:in `execute'
/var/www/discourse/app/jobs/base.rb:292:in `block (2 levels) in perform'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-5.0.0/lib/rails_multisite/connection_management.rb:82:in `with_connection'
/var/www/discourse/app/jobs/base.rb:279:in `block in perform'
/var/www/discourse/app/jobs/base.rb:275:in `each'
您需要在 ai_hugging_face_api_url 下设置该服务的 URL。
看起来可用的摘要策略不支持我正在运行的模型。
ghcr.io/huggingface/text-generation-inference:1.3 --model-id tiiuae/falcon-7b-instruct
我只是想知道,如果您安装并运行Toxicity分类服务,如何将其停用或正确卸载?谢谢。

