初始化参数(Initialization Parameter)知识合集 based on 11g

本文深入解析Oracle数据库初始化参数,涵盖pfile与spfile的区别、参数类型、调用顺序及参数修改方法。了解如何通过不同方式启动数据库,掌握参数配置与调整技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

初始化参数文件分为:

1)pfile 静态参数文件

2)spfile 动态服务器参数文件

作用:存储建立实例、启动后台进程所需参数值。

调用:实例启动时,按如下顺序调取初始化参数文件

linux:

$ORACLE_HOME/dbs/spfile<SID>.ora

$ORACLE_HOME/dbs/spfile.ora

$ORACLE_HOME/dbs/init<SID>.ora

windows:

%ORACLE_HOME%\database\SPFILE<SID>.ORA

%ORACLE_HOME%\database\SPFILE.ORA

%ORACLE_HOME%\database\INIT<SID>.ORA

或者启动时指定pfile

startup open pfile='/home/oracle/init.ora';  

实例从关闭状态启动到nomount(started状态)时需要用到初始化参数文件。

spfile是服务器端文件,实例启动时被SMON读取,不能重命名和移动位置,它是二进制文件,不能手工编辑;pfile是客户端文件,实例启动时由用户进程读取,可以随意重命名或 移动后通过制定其名称和位置来启动数据库,它是ASCII文本文件,可以编辑。

spfile是二进制文件,可以用strings命令来查看内部的参数信息:

可以在数据库的任何状态下(即使是关闭状态下)用以下语句做初始化参数文件的转换:

CREATE SPFILE [=[fiilepath/]filename] FROM PFILE [=[fiilepath/]filename] ;
CREATE PFILE [=[fiilepath/]filename] FROM SPFILE [=[fiilepath/]filename] ;

此时的SQLPLUS仅仅是一个转化工具而已,要求FROM后面的初始化参数文件必须存在。

还可以

CREATE PFILE [=[fiilepath/]filename] FROM MEMORY;
CREATE SPFILE [=[fiilepath/]filename] FROM MEMORY;--当数据库不是用spfile启动的时候才能这样操作

动态参数:可在实例运行时更改的参数,可以写入内存立即生效,可以写入spfile保存设置,部分动态参数支持session级别的更改。

静态参数:在实例启动时就固定下来,即使更改也只先写入spfile,需重启实例才能启用新值的参数。

v$parameter显示当前实例生效的参数信息(已导入内存中的参数信息);v$spparameter显示磁盘中spfile中的值。

共342个参数,41个基本参数,301个非基本参数。

查看初始化参数配置:

 1)OEM:

2)v$parameter

3)show parameter command

更改初始化参数

1)更改动态参数,立即生效,不写入spfile,重启后恢复原来的值

alter system set db_file_multiblock_read_count=16 scope=memory;

2)更改动态参数,立即生效,写入spfile,重启后继续使用当前值

alter system set db_file_multiblock_read_count=16 scope=both;

3)更改静态参数,写入spfile,需实例重启后方才生效

alter system set db_file_multiblock_read_count=16 scope=spfile;

4)按会话级别动态更改,仅当前会话有效

alter session set optimizer_mode=first_rows;

 用pfile启动数据库时,若改动spfile内的参数(scope=spfile),会报错

数据库至少启动到nomount下可修改参数。关闭状态下不允许修改。

 

转载于:https://www.cnblogs.com/Elaine-Lan/p/9886936.html

Parameters for big model inference torch_dtype (str or torch.dtype, optional) — Override the default torch.dtype and load the model under a specific dtype. The different options are: torch.float16 or torch.bfloat16 or torch.float: load in a specified dtype, ignoring the model’s config.torch_dtype if one exists. If not specified the model will get loaded in torch.float (fp32). "auto" - A torch_dtype entry in the config.json file of the model will be attempted to be used. If this entry isn’t found then next check the dtype of the first weight in the checkpoint that’s of a floating point type and use that as dtype. This will load the model using the dtype it was saved in at the end of the training. It can’t be used as an indicator of how the model was trained. Since it could be trained in one of half precision dtypes, but saved in fp32. A string that is a valid torch.dtype. E.g. “float32” loads the model in torch.float32, “float16” loads in torch.float16 etc. For some models the dtype they were trained in is unknown - you may try to check the model’s paper or reach out to the authors and ask them to add this information to the model’s card and to insert the torch_dtype entry in config.json on the hub. device_map (str or dict[str, Union[int, str, torch.device]] or int or torch.device, optional) — A map that specifies where each submodule should go. It doesn’t need to be refined to each parameter/buffer name, once a given module name is inside, every submodule of it will be sent to the same device. If we only pass the device (e.g., "cpu", "cuda:1", "mps", or a GPU ordinal rank like 1) on which the model will be allocated, the device map will map the entire model to this device. Passing device_map = 0 means put the whole model on GPU 0. To have Accelerate compute the most optimized device_map automatically, set device_map="auto". For more information about each option see designing a device map. max_memory (Dict, optional) — A dictionary device identifier to maximum memory if using device_map. Will default to the maximum memory available for each GPU and the available CPU RAM if unset. tp_plan (str, optional) — A torch tensor parallel plan, see here. Currently, it only accepts tp_plan="auto" to use predefined plan based on the model. Note that if you use it, you should launch your script accordingly with torchrun [args] script.py. This will be much faster than using a device_map, but has limitations. tp_size (str, optional) — A torch tensor parallel degree. If not provided would default to world size. device_mesh (torch.distributed.DeviceMesh, optional) — A torch device mesh. If not provided would default to world size. Used only for tensor parallel for now. offload_folder (str or os.PathLike, optional) — If the device_map contains any value "disk", the folder where we will offload weights. offload_state_dict (bool, optional) — If True, will temporarily offload the CPU state dict to the hard drive to avoid getting out of CPU RAM if the weight of the CPU state dict + the biggest shard of the checkpoint does not fit. Defaults to True when there is some disk offload. offload_buffers (bool, optional) — Whether or not to offload the buffers with the model parameters. quantization_config (Union[QuantizationConfigMixin,Dict], optional) — A dictionary of configuration parameters or a QuantizationConfigMixin object for quantization (e.g bitsandbytes, gptq). There may be other quantization-related kwargs, including load_in_4bit and load_in_8bit, which are parsed by QuantizationConfigParser. Supported only for bitsandbytes quantizations and not preferred. consider inserting all such arguments into quantization_config instead. subfolder (str, optional, defaults to "") — In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can specify the folder name here. variant (str, optional) — If specified load weights from variant filename, e.g. pytorch_model..bin. variant is ignored when using from_tf or from_flax. use_safetensors (bool, optional, defaults to None) — Whether or not to use safetensors checkpoints. Defaults to None. If not specified and safetensors is not installed, it will be set to False. weights_only (bool, optional, defaults to True) — Indicates whether unpickler should be restricted to loading only tensors, primitive types, dictionaries and any types added via torch.serialization.add_safe_globals(). When set to False, we can load wrapper tensor subclass weights. key_mapping (`dict[str, str], optional) — A potential mapping of the weight names if using a model on the Hub which is compatible to a Transformers architecture, but was not converted accordingly. kwargs (remaining dictionary of keyword arguments, optional) — Can be used to update the configuration object (after it being loaded) and initiate the model (e.g., output_attentions=True). Behaves differently depending on whether a config is provided or automatically loaded: If a configuration is provided with config, **kwargs will be directly passed to the underlying model’s __init__ method (we assume all relevant updates to the configuration have already been done) If a configuration is not provided, kwargs will be first passed to the configuration class initialization function (from_pretrained()). Each key of kwargs that corresponds to a configuration attribute will be used to override said attribute with the supplied kwargs value. Remaining keys that do not correspond to any configuration attribute will be passed to the underlying model’s __init__ function. 详细解释一下上面这个
最新发布
07-25
<think>我们被要求详细解释大模型推理中的参数。这些参数主要来自Hugging Face的`transformers`库中模型加载函数(如`from_pretrained`)的常见参数。下面将逐一解释每个参数的含义和用法。</think>### 大模型推理参数详解 #### 1. `torch_dtype` (可选) - **作用**:指定模型加载的数据类型 - **选项**: - `torch.float16`:半精度(FP16),节省显存但可能损失精度 - `torch.bfloat16`:脑浮点数(BF16),保持动态范围,适合大型模型 - `torch.float`:单精度(FP32),最高精度但显存占用最大 - `"auto"`:自动选择(优先级): 1. 优先使用模型`config.json`中的`torch_dtype`设置 2. 若无则使用checkpoint中第一个浮点权重的数据类型 3. 默认回退到`torch.float` - **示例**: ```python model = AutoModelForCausalLM.from_pretrained( "meta-llama/Llama-3-70B", torch_dtype=torch.bfloat16 # 显式指定BF16 ) ``` #### 2. `device_map` (可选) - **作用**:控制模型各层在设备间的分布 - **配置方式**: - `"auto"`:自动优化分配(推荐) - 设备标识符:如`"cuda:0"`(GPU 0)、`"cpu"`(CPU) - 详细映射字典:如`{"layer1": 0, "layer2": "cpu"}` - **特殊值**: - `0` 或 `"cuda:0"`:整个模型放在GPU 0 - `"mps"`:Apple Silicon芯片专用 - **示例**: ```python # 自动分配模型到可用设备 model = AutoModel.from_pretrained("bigscience/bloom", device_map="auto") ``` #### 3. `max_memory` (可选) - **作用**:指定各设备的最大内存限制 - **格式**:字典,如`{0: "20GB", "cpu": "64GB"}` - **典型场景**: - 限制GPU显存使用避免OOM - 控制CPU内存使用 - **注意**:未设置时自动使用设备最大可用内存 #### 4. `tp_plan` 和 `tp_size` (可选) - **作用**:张量并行配置(分布式推理) - **参数**: - `tp_plan="auto"`:使用预设的并行策略 - `tp_size`:并行度(通常等于GPU数量) - **要求**: ```bash torchrun --nproc_per_node=4 inference.py # 启动4个进程 ``` #### 5. `offload_folder` 和 `offload_state_dict` - **作用**:显存不足时将权重卸载到磁盘 - **配置**: - `offload_folder`:指定磁盘缓存路径 - `offload_state_dict=True`:自动卸载状态字典(默认启用) - **典型值**: ```python model = AutoModel.from_pretrained( "bigscience/mt0-xxl", device_map={"": 0}, # 主设备 offload_folder="./offload", # 磁盘缓存目录 offload_state_dict=True ) ``` #### 6. `quantization_config` (可选) - **作用**:模型量化配置 - **兼容方案**: - `bitsandbytes`(4-bit/8-bit量化) - `gptq`(GPT量化) - **注意**:优先使用此参数而非单独的`load_in_4bit` #### 7. 其他关键参数 | 参数 | 作用 | 示例值 | |------|------|--------| | `subfolder` | 指定HF仓库中的子目录 | `subfolder="lora_weights"` | | `variant` | 加载特定变体文件 | `variant="fp16"`(加载`pytorch_model.fp16.bin`) | | `use_safetensors` | 使用安全张量格式 | `use_safetensors=True`(需安装`safetensors`) | | `weights_only` | 限制反序列化类型 | `weights_only=True`(增强安全性) | | `key_mapping` | 权重名称映射 | `key_mapping={"old_key": "new_key"}` | #### 8. 特殊处理逻辑 ```mermaid graph LR A[加载配置] --> B{有显式config?} B -->|是| C[直接初始化模型] B -->|否| D[用kwargs更新配置] D --> E[用更新后配置初始化模型] C --> F[未匹配kwargs传给模型] E --> F ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值