[{"data":1,"prerenderedAt":429},["ShallowReactive",2],{"/open_source/best_practice/network_workarounds":3,"surround-/open_source/best_practice/network_workarounds":415},{"id":4,"title":5,"avatar":6,"banner":6,"body":7,"category":6,"desc":408,"description":45,"extension":409,"links":6,"meta":410,"navigation":6,"path":411,"seo":412,"stem":413,"__hash__":414},"docs/en/open_source/best_practice/network_workarounds.md","Network Environment Adaptation",null,{"type":8,"value":9,"toc":399},"minimark",[10,18,23,27,133,143,147,150,250,258,264,268,271,325,334,353,360,386,395],[11,12,14],"h2",{"id":13},"downloading-huggingface-models",[15,16,17],"strong",{},"Downloading Huggingface Models",[19,20,22],"h3",{"id":21},"mirror-site-hf-mirror","Mirror Site (HF-Mirror)",[24,25,26],"p",{},"To download Huggingface models using the mirror site, you can follow these steps:",[28,29,31,36,39,68,72,83,87,90],"steps",{"level":30},"4",[32,33,35],"h4",{"id":34},"install-dependencies","Install Dependencies",[24,37,38],{},"Install the necessary dependencies by running:",[40,41,46],"pre",{"className":42,"code":43,"language":44,"meta":45,"style":45},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pip install -U huggingface_hub\n","bash","",[47,48,49],"code",{"__ignoreMap":45},[50,51,54,58,62,65],"span",{"class":52,"line":53},"line",1,[50,55,57],{"class":56},"sBMFI","pip",[50,59,61],{"class":60},"sfazB"," install",[50,63,64],{"class":60}," -U",[50,66,67],{"class":60}," huggingface_hub\n",[32,69,71],{"id":70},"set-environment-variable","Set Environment Variable",[24,73,74,75,78,79,82],{},"Set the environment variable ",[47,76,77],{},"HF_ENDPOINT"," to ",[47,80,81],{},"https://hf-mirror.com",".",[32,84,86],{"id":85},"download-models-or-datasets","Download Models or Datasets",[24,88,89],{},"Use huggingface-cli to download models or datasets. For example:",[91,92,93,122],"ul",{},[94,95,96,97],"li",{},"To download a model:",[40,98,100],{"className":42,"code":99,"language":44,"meta":45,"style":45},"huggingface-cli download --resume-download gpt2 --local-dir gpt2\n",[47,101,102],{"__ignoreMap":45},[50,103,104,107,110,113,116,119],{"class":52,"line":53},[50,105,106],{"class":56},"huggingface-cli",[50,108,109],{"class":60}," download",[50,111,112],{"class":60}," --resume-download",[50,114,115],{"class":60}," gpt2",[50,117,118],{"class":60}," --local-dir",[50,120,121],{"class":60}," gpt2\n",[94,123,124,125],{},"To download a dataset:",[40,126,131],{"className":127,"code":129,"language":130},[128],"language-text","huggingface-cli download --repo-type dataset --resume-download wikitext --local-dir wikitext\n","text",[47,132,129],{"__ignoreMap":45},[24,134,135,136,82],{},"For more detailed instructions and additional methods, please refer to ",[137,138,142],"a",{"href":139,"rel":140},"https://hf-mirror.com/",[141],"nofollow","this link",[19,144,146],{"id":145},"alternative-sources","Alternative Sources",[24,148,149],{},"You may still encounter limitations accessing some models in your regions. In such cases, you can use modelscope:",[28,151,152,156,158,172,175,178],{"level":30},[32,153,155],{"id":154},"install-modelscope","Install ModelScope",[24,157,38],{},[40,159,161],{"className":42,"code":160,"language":44,"meta":45,"style":45},"pip install modelscope[framework]\n",[47,162,163],{"__ignoreMap":45},[50,164,165,167,169],{"class":52,"line":53},[50,166,57],{"class":56},[50,168,61],{"class":60},[50,170,171],{"class":60}," modelscope[framework]\n",[32,173,86],{"id":174},"download-models-or-datasets-1",[24,176,177],{},"Use modelscope to download models or datasets. For example:",[91,179,180,218],{},[94,181,96,182],{},[40,183,185],{"className":42,"code":184,"language":44,"meta":45,"style":45},"modelscope download --model 'Qwen/Qwen2-7b' --local_dir 'path/to/dir'\n",[47,186,187],{"__ignoreMap":45},[50,188,189,192,194,197,201,204,207,210,212,215],{"class":52,"line":53},[50,190,191],{"class":56},"modelscope",[50,193,109],{"class":60},[50,195,196],{"class":60}," --model",[50,198,200],{"class":199},"sMK4o"," '",[50,202,203],{"class":60},"Qwen/Qwen2-7b",[50,205,206],{"class":199},"'",[50,208,209],{"class":60}," --local_dir",[50,211,200],{"class":199},[50,213,214],{"class":60},"path/to/dir",[50,216,217],{"class":199},"'\n",[94,219,124,220],{},[40,221,223],{"className":42,"code":222,"language":44,"meta":45,"style":45},"modelscope download --dataset 'Tongyi-DataEngine/SA1B-Dense-Caption' --local_dir './local_dir'\n",[47,224,225],{"__ignoreMap":45},[50,226,227,229,231,234,236,239,241,243,245,248],{"class":52,"line":53},[50,228,191],{"class":56},[50,230,109],{"class":60},[50,232,233],{"class":60}," --dataset",[50,235,200],{"class":199},[50,237,238],{"class":60},"Tongyi-DataEngine/SA1B-Dense-Caption",[50,240,206],{"class":199},[50,242,209],{"class":60},[50,244,200],{"class":199},[50,246,247],{"class":60},"./local_dir",[50,249,217],{"class":199},[24,251,252,253,82],{},"For more detailed instructions and additional methods, please refer to the ",[137,254,257],{"href":255,"rel":256},"https://modelscope.cn/docs/home",[141],"official docs",[11,259,261],{"id":260},"using-poetry",[15,262,263],{},"Using Poetry",[19,265,267],{"id":266},"network-errors-during-installing","Network Errors during Installing",[24,269,270],{},"To address network errors when using \"poetry install\" in your regions, you can follow these steps:",[28,272,273,277,284,314,318],{"level":30},[32,274,276],{"id":275},"update-configuration","Update Configuration",[24,278,279,280,283],{},"Update the ",[47,281,282],{},"pyproject.toml"," file to use a mirror source by adding the following configuration:",[40,285,289],{"className":286,"code":287,"language":288,"meta":45,"style":45},"language-toml shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","[[tool.poetry.source]]\nname = \"mirrors\"\nurl = \"https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/\"\npriority = \"primary\"\n","toml",[47,290,291,296,302,308],{"__ignoreMap":45},[50,292,293],{"class":52,"line":53},[50,294,295],{},"[[tool.poetry.source]]\n",[50,297,299],{"class":52,"line":298},2,[50,300,301],{},"name = \"mirrors\"\n",[50,303,305],{"class":52,"line":304},3,[50,306,307],{},"url = \"https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/\"\n",[50,309,311],{"class":52,"line":310},4,[50,312,313],{},"priority = \"primary\"\n",[32,315,317],{"id":316},"reconfigure-poetry","Reconfigure Poetry",[24,319,320,321,324],{},"Run the command ",[47,322,323],{},"poetry lock"," in the terminal to reconfigure Poetry with the new mirror source.",[24,326,327,330,331,333],{},[15,328,329],{},"Tips:","\nBe aware that ",[47,332,323],{}," will modify both Pyproject.toml and poetry.lock files. To avoid committing redundant changes:",[91,335,336,346],{},[94,337,338,339,342,343,82],{},"Option 1: After successful ",[47,340,341],{},"poetry install",", revert to the git HEAD node using ",[47,344,345],{},"git reset --hard HEAD",[94,347,348,349,352],{},"Option 2: When executing ",[47,350,351],{},"git add",", exclude the Pyproject.toml and poetry.lock files by specifying other files.",[24,354,355,356,359],{},"For future dependency management tasks like adding or removing packages, you can use the ",[47,357,358],{},"poetry add"," command:",[40,361,363],{"className":42,"code":362,"language":44,"meta":45,"style":45},"poetry add \u003Clib_name>\n",[47,364,365],{"__ignoreMap":45},[50,366,367,370,373,376,379,383],{"class":52,"line":53},[50,368,369],{"class":56},"poetry",[50,371,372],{"class":60}," add",[50,374,375],{"class":199}," \u003C",[50,377,378],{"class":60},"lib_nam",[50,380,382],{"class":381},"sTEyZ","e",[50,384,385],{"class":199},">\n",[24,387,388,389,394],{},"Refer to the ",[137,390,393],{"href":391,"rel":392},"https://python-poetry.org/docs/cli/",[141],"Poetry CLI documentation"," for more commands and details.",[396,397,398],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}",{"title":45,"searchDepth":298,"depth":298,"links":400},[401,405],{"id":13,"depth":298,"text":17,"children":402},[403,404],{"id":21,"depth":304,"text":22},{"id":145,"depth":304,"text":146},{"id":260,"depth":298,"text":263,"children":406},[407],{"id":266,"depth":304,"text":267},"The following are some solutions to network issues that may be encountered during development.","md",{},"/en/open_source/best_practice/network_workarounds",{"title":5,"description":45},"en/open_source/best_practice/network_workarounds","ZgCpkzGjjnuziw92O69PGUV76EQtqzkBWpwSVBpfztQ",[416,423],{"title":417,"path":418,"stem":419,"icon":420,"framework":6,"module":6,"class":421,"target":-1,"active":422,"defaultOpen":422,"children":-1,"description":-1},"Performance Tuning","/open_source/best_practice/performance_tuning","open_source/best_practice/performance_tuning","i-ri-speed-line",[],false,{"title":424,"path":425,"stem":426,"icon":427,"framework":6,"module":6,"class":428,"target":-1,"active":422,"defaultOpen":422,"children":-1,"description":-1},"Common Errors & Solutions","/open_source/best_practice/common_errors_solutions","open_source/best_practice/common_errors_solutions","i-ri-error-warning-line",[],1770372089340]