大佬好!我部署了一个 Ubuntu 22.04 环境,2x24GB 显卡,128GB CPU,CUDA 11.8,Python 3.10.13 with Conda。
Linux Conda 虚拟环境下,Python 版本和依赖跟之前 Windows 环境一样,2块4090。
不设置 export CUDA_VISIBLE_DEVICES=0 情况下,两块显卡自动均分加载模型,这个挺好。
以下是运行日志(由于提交内容太长。我把中间部分的 Tensor 输出给删了省略了):
(code) tkadmin@ubu:~/AutoCoder$ python chatbot.py
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
IMPORTANT: You are using gradio version 3.48.0, however version 4.29.0 is available, please upgrade.
[2024-05-30 13:22:09,739] [INFO] [real_accelerator.py:158:get_accelerator] Setting ds_accelerator to cuda (auto detect)
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:03<00:00, 1.06s/it]
Running on local URL: http://0.0.0.0:10518
To create a public link, set share=True
in launch()
.
INFO:root:allocating new uuid 0ef99ba0-4085-4963-85ca-954097161a80 for conversation...
INFO:root:user message:
Write a script in Python and draw a heart-shaped pattern and verify it
INFO:root:inputs:
tensor([[ 39, 8384, 25, 17437, 245, 4744, 279, 13003, 285, 4293,
245, 2986, 12, 25269, 7949, 285, 12909, 359, 185, 5618,
15481, 25, 207]])
INFO:root:kwargs:
{'input_ids': tensor([[ 39, 8384, 25, 17437, 245, 4744, 279, 13003, 285, 4293,
245, 2986, 12, 25269, 7949, 285, 12909, 359, 185, 5618,
15481, 25, 207]], device='cuda:0'), 'streamer': <transformers.generation.streamers.TextIteratorStreamer object at 0x7fc6ba5b4400>, 'max_new_tokens': 1024, 'do_sample': True, 'top_k': 50, 'top_p': 0.95, 'eos_token_id': 32021, 'pad_token_id': 32021}
generated_text Sure, here is a basic script that uses the Turtle Graphics library to draw a heart-shaped pattern. We will use a simple square and circle function to draw this shape.
import turtle
# function to draw square
def draw_square(side_length, color):
turtle.color(color)
turtle.begin_fill()
for _ in range(4):
turtle.forward(side_length)
turtle.right(90)
turtle.end_fill()
# function to draw circle
def draw_circle(radius, color):
turtle.color(color)
turtle.begin_fill()
turtle.circle(radius)
turtle.end_fill()
# function to draw heart shape
def draw_heart():
# Set the fill color
turtle.fillcolor("red")
# Draw square
draw_square(150, "red")
# Move to start of heart
turtle.penup()
turtle.goto(-75, 125)
turtle.pendown()
# Draw circle
draw_circle(75, "red")
# Move to the center of the heart
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
# Draw circle
draw_circle(75, "red")
# Move to the end of the heart
turtle.penup()
turtle.goto(75, 125)
turtle.pendown()
# Draw circle
draw_circle(75, "red")
# Draw the heart
draw_heart()
# To keep the window open
turtle.mainloop()
When you run this script, it will open a window and display a red heart-shaped pattern. It can be tested to verify its accuracy.<|EOT|>
INFO:root:saving current dialog to file 0ef99ba0-4085-4963-85ca-954097161a80.json...
INFO:root:current dialog: [{'role': 'user', 'content': 'Write a script in Python and draw a heart-shaped pattern and verify it'}, {'role': 'assistant', 'content': 'Sure, here is a basic script that uses the Turtle Graphics library to draw a heart-shaped pattern. We will use a simple square and circle function to draw this shape.\n\npython\nimport turtle\n\n# function to draw square\ndef draw_square(side_length, color):\n turtle.color(color)\n turtle.begin_fill()\n for _ in range(4):\n turtle.forward(side_length)\n turtle.right(90)\n turtle.end_fill()\n\n# function to draw circle\ndef draw_circle(radius, color):\n turtle.color(color)\n turtle.begin_fill()\n turtle.circle(radius)\n turtle.end_fill()\n\n# function to draw heart shape\ndef draw_heart():\n # Set the fill color\n turtle.fillcolor("red")\n\n # Draw square\n draw_square(150, "red")\n\n # Move to start of heart\n turtle.penup()\n turtle.goto(-75, 125)\n turtle.pendown()\n\n # Draw circle\n draw_circle(75, "red")\n\n # Move to the center of the heart\n turtle.penup()\n turtle.goto(0, 0)\n turtle.pendown()\n\n # Draw circle\n draw_circle(75, "red")\n\n # Move to the end of the heart\n turtle.penup()\n turtle.goto(75, 125)\n turtle.pendown()\n\n # Draw circle\n draw_circle(75, "red")\n\n# Draw the heart\ndraw_heart()\n\n# To keep the window open\nturtle.mainloop()\n
\nWhen you run this script, it will open a window and display a red heart-shaped pattern. It can be tested to verify its accuracy.'}]
ed8490a3da0b2c2f04c49154379b53a357ac00c28e22a771730ef13615eecad9
HAS_Code:False
INFO:root:user message:
please run the script to verify
INFO:root:inputs:
tensor([[ 39, 8384, 25, 17437, 245, 4744, 279, 13003, 285, 4293,
........
12909, 185, 5618, 15481, 25, 207]])
INFO:root:kwargs:
{'input_ids': tensor([[ 39, 8384, 25, 17437, 245, 4744, 279, 13003, 285, 4293,
........
32014, 185, 39, 8384, 25, 4058, 1404, 254, 4744, 276,
12909, 185, 5618, 15481, 25, 207]], device='cuda:0'), 'streamer': <transformers.generation.streamers.TextIteratorStreamer object at 0x7fc6ba5b56f0>, 'max_new_tokens': 1024, 'do_sample': True, 'top_k': 50, 'top_p': 0.95, 'eos_token_id': 32021, 'pad_token_id': 32021}
generated_text
We need to execute the code to see if it's working properly.
Our initial task should be to install the related packages.
<API_RUN_START>```sh
pip install numpy
We can proceed to execute the code:
<API_RUN_START>```python
import numpy as np
def generate_data_and_save(file_path, size):
# Generate random 2D data
data = np.random.rand(size, size)
# Save data to a file
np.save(file_path, data)
print(f"Data saved to: {file_path}")
def load_data_and_process(file_path):
# Load the data
data = np.load(file_path)
# Apply some processing (e.g., element-wise multiplication)
processed_data = data * 2
return processed_data
def main():
# Define the path where the data will be saved
data_file_path = "random_data.npy"
# Generate and save data
generate_data_and_save(data_file_path, 1000)
# Load and process data
processed_data = load_data_and_process(data_file_path)
# Optionally, check the output
print(processed_data)
print("Processed data successfully loaded.")
if __name__ == "__main__":
main()
```<API_RUN_STOP><|EOT|>
INFO:root:saving current dialog to file 0ef99ba0-4085-4963-85ca-954097161a80.json...
INFO:root:current dialog: [{'role': 'user', 'content': 'Write a script in Python and draw a heart-shaped pattern and verify it'}, {'role': 'assistant', 'content': 'Sure, here is a basic script that uses the Turtle Graphics library to draw a heart-shaped pattern. We will use a simple square and circle function to draw this shape.\n\n```python\nimport turtle\n\n# function to draw square\ndef draw_square(side_length, color):\n turtle.color(color)\n turtle.begin_fill()\n for _ in range(4):\n turtle.forward(side_length)\n turtle.right(90)\n turtle.end_fill()\n\n# function to draw circle\ndef draw_circle(radius, color):\n turtle.color(color)\n turtle.begin_fill()\n turtle.circle(radius)\n turtle.end_fill()\n\n# function to draw heart shape\ndef draw_heart():\n # Set the fill color\n turtle.fillcolor("red")\n\n # Draw square\n draw_square(150, "red")\n\n # Move to start of heart\n turtle.penup()\n turtle.goto(-75, 125)\n turtle.pendown()\n\n # Draw circle\n draw_circle(75, "red")\n\n # Move to the center of the heart\n turtle.penup()\n turtle.goto(0, 0)\n turtle.pendown()\n\n # Draw circle\n draw_circle(75, "red")\n\n # Move to the end of the heart\n turtle.penup()\n turtle.goto(75, 125)\n turtle.pendown()\n\n # Draw circle\n draw_circle(75, "red")\n\n# Draw the heart\ndraw_heart()\n\n# To keep the window open\nturtle.mainloop()\n```\nWhen you run this script, it will open a window and display a red heart-shaped pattern. It can be tested to verify its accuracy.'}, {'role': 'user', 'content': 'please run the script to verify'}, {'role': 'assistant', 'content': '\nWe need to execute the code to see if it\'s working properly.\nOur initial task should be to install the related packages.\n<API_RUN_START>```sh\npip install numpy\n```<API_RUN_STOP>\nWe can proceed to execute the code:\n<API_RUN_START>```python\nimport numpy as np\n\ndef generate_data_and_save(file_path, size):\n # Generate random 2D data\n data = np.random.rand(size, size)\n # Save data to a file\n np.save(file_path, data)\n print(f"Data saved to: {file_path}")\n\ndef load_data_and_process(file_path):\n # Load the data\n data = np.load(file_path)\n # Apply some processing (e.g., element-wise multiplication)\n processed_data = data * 2\n return processed_data\n\ndef main():\n # Define the path where the data will be saved\n data_file_path = "random_data.npy"\n # Generate and save data\n generate_data_and_save(data_file_path, 1000)\n \n # Load and process data\n processed_data = load_data_and_process(data_file_path)\n \n # Optionally, check the output\n print(processed_data)\n print("Processed data successfully loaded.")\n\nif __name__ == "__main__":\n main()\n```<API_RUN_STOP>'}]
docker: Error response from daemon: Conflict. The container name "/container_python_0" is already in use by container "ed8490a3da0b2c2f04c49154379b53a357ac00c28e22a771730ef13615eecad9". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
Traceback (most recent call last):
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/gradio/queueing.py", line 407, in call_prediction
output = await route_utils.call_process_api(
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/gradio/route_utils.py", line 226, in call_process_api
output = await app.get_blocks().process_api(
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/gradio/blocks.py", line 1550, in process_api
result = await self.call_function(
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/gradio/blocks.py", line 1199, in call_function
prediction = await utils.async_iteration(iterator)
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/gradio/utils.py", line 519, in async_iteration
return await iterator.__anext__()
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/gradio/utils.py", line 512, in __anext__
return await anyio.to_thread.run_sync(
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2177, in run_sync_in_worker_thread
return await future
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 859, in run
result = context.run(func, *args)
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/gradio/utils.py", line 495, in run_sync_iterator_async
return next(iterator)
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/site-packages/gradio/utils.py", line 649, in gen_wrapper
yield from f(*args, **kwargs)
File "/home/tkadmin/AutoCoder/chatbot.py", line 247, in bot
subprocess.run(["docker", "run", "-d", "-v",
File "/home/tkadmin/miniconda3/envs/code/lib/python3.10/subprocess.py", line 526, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['docker', 'run', '-d', '-v', '/home/tkadmin/AutoCoder/sandbox/python_0:/app', '--name', 'container_python_0', 'python-sandbox_0', 'tail', '-f', '/dev/null']' returned non-zero exit status 125.
^CKeyboard interruption in main thread... closing server.
container_python_0
Container named container_python_0 has been removed.
从上面日志可以看出,容器 ed8490a3da0b2c2f04c49154379b53a357ac00c28e22a771730ef13615eecad9 是对话后新创建的。但为什么会提示已被占用?
tkadmin@ubu:~$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
python-sandbox_0 latest c4abb2fec3ac 10 minutes ago 1.02GB
tkadmin@ubu:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ed8490a3da0b python-sandbox_0 "tail -f /dev/null" 3 minutes ago Up 3 minutes container_python_0
从 docker 命令查询,可以看到,image 先创建,然后 7 分钟后,容器才被启动。
请大佬帮忙分析分析,为什么容器使用有冲突了,谢谢!
Web 界面如下:
![ubuntu-2024-05-30_132843](https://github.com/bin123apple/AutoCoder/assets/131220899/5152f086-3bc2-4093-9d8d-eb86232fc5e9)