当前位置:   article > 正文

ChatGlm-6B多张显卡的web_demo.py_load_model_on_gpus

load_model_on_gpus
  1. from transformers import AutoModel, AutoTokenizer
  2. import gradio as gr
  3. import mdtex2html
  4. from utils import load_model_on_gpus #要加的包
  5. import os #要加的包
  6. os.environ["CUDA_VISIBLE_DEVICES"]='0,1' #把显卡加到全局变量中
  7. tokenizer = AutoTokenizer.from_pretrained("chatglm-6b", trust_remote_code=True)
  8. model = load_model_on_gpus("chatglm-6b",num_gpus=2)#使用两块显卡
  9. # model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().cuda()
  10. model = model.eval()

在运行上面的代码需要保证你的显卡的驱动已经安装,需要验证以下代码反回为true

  1. import torch
  2. print(torch.cuda.is_available())
  3. True
  4. Print(torch.cuda.device_count())
  5. 2

以下是我运行ChatGlm的pip list

  1. (glm) root@gpt:/home/gpt# pip list
  2. Package Version
  3. ------------------ ------------
  4. accelerate 0.19.0
  5. aiofiles 23.1.0
  6. aiohttp 3.8.4
  7. aiosignal 1.3.1
  8. altair 4.2.2
  9. anyio 3.6.2
  10. async-timeout 4.0.2
  11. attrs 23.1.0
  12. certifi 2022.12.7
  13. charset-normalizer 2.1.1
  14. click 8.1.3
  15. cmake 3.25.0
  16. contourpy 1.0.7
  17. cpm-kernels 1.0.11
  18. cycler 0.11.0
  19. entrypoints 0.4
  20. fastapi 0.95.1
  21. ffmpy 0.3.0
  22. filelock 3.9.0
  23. fonttools 4.39.3
  24. frozenlist 1.3.3
  25. fsspec 2023.5.0
  26. gradio 3.28.3
  27. gradio_client 0.2.1
  28. h11 0.14.0
  29. httpcore 0.17.0
  30. httpx 0.24.0
  31. huggingface-hub 0.14.1
  32. idna 3.4
  33. Jinja2 3.1.2
  34. jsonschema 4.17.3
  35. kiwisolver 1.4.4
  36. latex2mathml 3.75.5
  37. linkify-it-py 2.0.2
  38. lit 15.0.7
  39. Markdown 3.4.3
  40. markdown-it-py 2.2.0
  41. MarkupSafe 2.1.2
  42. matplotlib 3.7.1
  43. mdit-py-plugins 0.3.3
  44. mdtex2html 1.2.0
  45. mdurl 0.1.2
  46. mpmath 1.2.1
  47. multidict 6.0.4
  48. networkx 3.0
  49. numpy 1.24.1
  50. orjson 3.8.12
  51. packaging 23.1
  52. pandas 2.0.1
  53. Pillow 9.3.0
  54. pip 23.0.1
  55. protobuf 4.23.0
  56. psutil 5.9.5
  57. pydantic 1.10.7
  58. pydub 0.25.1
  59. Pygments 2.15.1
  60. pyparsing 3.0.9
  61. pyrsistent 0.19.3
  62. python-dateutil 2.8.2
  63. python-multipart 0.0.6
  64. pytz 2023.3
  65. PyYAML 6.0
  66. regex 2023.5.5
  67. requests 2.28.1
  68. semantic-version 2.10.0
  69. sentencepiece 0.1.99
  70. setuptools 66.0.0
  71. six 1.16.0
  72. sniffio 1.3.0
  73. starlette 0.26.1
  74. sympy 1.11.1
  75. tokenizers 0.13.3
  76. toolz 0.12.0
  77. torch 2.0.1+cu118
  78. torchaudio 2.0.2+cu118
  79. torchvision 0.15.2+cu118
  80. tqdm 4.65.0
  81. transformers 4.27.1
  82. triton 2.0.0
  83. typing_extensions 4.4.0
  84. tzdata 2023.3
  85. uc-micro-py 1.0.2
  86. urllib3 1.26.13
  87. uvicorn 0.22.0
  88. websockets 11.0.3
  89. wheel 0.38.4
  90. yarl 1.9.2

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/article/detail/53710
推荐阅读
相关标签
  

闽ICP备14008679号