当前位置: 首页 > news >正文

有没有免费网站制作seo关键词优化举例

有没有免费网站制作,seo关键词优化举例,用tp5做网站,河北省建设工程造价管理协会网站文章目录 前言代码 前言 当我们需要对大规模的数据向量化以存到向量数据库中时,且服务器上有多个GPU可以支配,我们希望同时利用所有的GPU来并行这一过程,加速向量化。 代码 就几行代码,不废话了 from sentence_transformers i…

文章目录

  • 前言
  • 代码


前言

当我们需要对大规模的数据向量化以存到向量数据库中时,且服务器上有多个GPU可以支配,我们希望同时利用所有的GPU来并行这一过程,加速向量化。

代码

就几行代码,不废话了

from sentence_transformers import SentenceTransformer#Important, you need to shield your code with if __name__. Otherwise, CUDA runs into issues when spawning new processes.
if __name__ == '__main__':#Create a large list of 100k sentencessentences = ["This is sentence {}".format(i) for i in range(100000)]#Define the modelmodel = SentenceTransformer('all-MiniLM-L6-v2')#Start the multi-process pool on all available CUDA devicespool = model.start_multi_process_pool()#Compute the embeddings using the multi-process poolemb = model.encode_multi_process(sentences, pool)print("Embeddings computed. Shape:", emb.shape)#Optional: Stop the proccesses in the poolmodel.stop_multi_process_pool(pool)

注意:一定要加if __name__ == '__main__':这一句,不然报如下错:

RuntimeError: An attempt has been made to start a new process before thecurrent process has finished its bootstrapping phase.This probably means that you are not using fork to start yourchild processes and you have forgotten to use the proper idiomin the main module:if __name__ == '__main__':freeze_support()...The "freeze_support()" line can be omitted if the programis not going to be frozen to produce an executable.

其实官方已经给出代码啦,我只不过复制粘贴了一下,代码位置:computing_embeddings_multi_gpu.py

官方还给出了流式encode的例子,也是多GPU并行的,如下:

from sentence_transformers import SentenceTransformer, LoggingHandler
import logging
from datasets import load_dataset
from torch.utils.data import DataLoader
from tqdm import tqdmlogging.basicConfig(format='%(asctime)s - %(message)s',datefmt='%Y-%m-%d %H:%M:%S',level=logging.INFO,handlers=[LoggingHandler()])#Important, you need to shield your code with if __name__. Otherwise, CUDA runs into issues when spawning new processes.
if __name__ == '__main__':#Set paramsdata_stream_size = 16384  #Size of the data that is loaded into memory at oncechunk_size = 1024  #Size of the chunks that are sent to each processencode_batch_size = 128  #Batch size of the model#Load a large dataset in streaming mode. more info: https://huggingface.co/docs/datasets/streamdataset = load_dataset('yahoo_answers_topics', split='train', streaming=True)dataloader = DataLoader(dataset.with_format("torch"), batch_size=data_stream_size)#Define the modelmodel = SentenceTransformer('all-MiniLM-L6-v2')#Start the multi-process pool on all available CUDA devicespool = model.start_multi_process_pool()for i, batch in enumerate(tqdm(dataloader)):#Compute the embeddings using the multi-process poolsentences = batch['best_answer']batch_emb = model.encode_multi_process(sentences, pool, chunk_size=chunk_size, batch_size=encode_batch_size)print("Embeddings computed for 1 batch. Shape:", batch_emb.shape)#Optional: Stop the proccesses in the poolmodel.stop_multi_process_pool(pool)

官方案例:computing_embeddings_streaming.py

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.105.01   Driver Version: 515.105.01   CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| 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  NVIDIA A800-SXM...  On   | 00000000:23:00.0 Off |                    0 |
| N/A   58C    P0   297W / 400W |  75340MiB / 81920MiB |    100%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   1  NVIDIA A800-SXM...  On   | 00000000:29:00.0 Off |                    0 |
| N/A   71C    P0   352W / 400W |  80672MiB / 81920MiB |    100%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   2  NVIDIA A800-SXM...  On   | 00000000:52:00.0 Off |                    0 |
| N/A   68C    P0   398W / 400W |  75756MiB / 81920MiB |    100%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   3  NVIDIA A800-SXM...  On   | 00000000:57:00.0 Off |                    0 |
| N/A   58C    P0   341W / 400W |  75994MiB / 81920MiB |    100%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   4  NVIDIA A800-SXM...  On   | 00000000:8D:00.0 Off |                    0 |
| N/A   56C    P0   319W / 400W |  70084MiB / 81920MiB |    100%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   5  NVIDIA A800-SXM...  On   | 00000000:92:00.0 Off |                    0 |
| N/A   70C    P0   354W / 400W |  76314MiB / 81920MiB |    100%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   6  NVIDIA A800-SXM...  On   | 00000000:BF:00.0 Off |                    0 |
| N/A   73C    P0   360W / 400W |  75876MiB / 81920MiB |    100%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   7  NVIDIA A800-SXM...  On   | 00000000:C5:00.0 Off |                    0 |
| N/A   57C    P0   364W / 400W |  80404MiB / 81920MiB |    100%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+

嘎嘎快啊

http://www.hkea.cn/news/206191/

相关文章:

  • 老外做的汉字网站一键生成app制作器
  • 网上设计接单的网站seo排名优化排行
  • wordpress后台加统计代码seo建站的步骤
  • 怎么做外贸网站的邮箱签名搜索引擎优化是指什么
  • 网页制作基础教程免费邯郸网站seo
  • phpcms做网站感想漯河seo推广
  • 公司部门kpi绩效考核指标模板河北百度seo软件
  • 印团网网站是哪家做的唯尚广告联盟
  • 网红营销网站seo综合查询怎么用的
  • 西安地区网站建设云推广
  • wordpress个人站2020年关键词排名
  • 网站建设企业公司石家庄新闻头条新闻最新今天
  • 道滘镇做网站百度统计
  • qq空间做宣传网站怎样建立自己的网站平台
  • 做设计一般用的素材网站是什么意思刷网站排名软件
  • 帮人做兼职的网站吗青岛seo服务哪家好
  • 贷款类网站怎样做网络营销的推广
  • 乐清做网站哪家好税收大数据
  • 校园网站建设需求天津放心站内优化seo
  • 哈尔滨微网站建设热搜在哪里可以看
  • 网站用oracle做数据库福州seo推广服务
  • 康保县城乡建设委员会网站营销型网站重要特点是
  • 手机做网站的步骤跨境电商有哪些平台
  • 请人做网站要多少网络事件营销
  • 网站页脚有什么作用厦门seo哪家强
  • 东莞百度提升优化优化推广网站推荐
  • 查企业网站有哪些站长统计app软件
  • 做a高清视频在线观看网站济源新站seo关键词排名推广
  • 刚做的网站怎么搜索不出来百度seo收录软件
  • 视频拍摄app站长工具seo综合查询广告